1 #include <stdio.h> 2 3 int main(){ 4 int n; 5 int number; 6 int i; 7 int j; 8 int array1[101]; 9 int array2[101]; 10 int length1; 11 int length2; 12 int temp; 13 14 while(scanf("%d",&n)!=EOF){ 15 length1=0; 16 for(i=0;i<n;i++){ 17 scanf("%d",&number); 18 19 if(i==0){ 20 array1[0]=number; 21 length1++; 22 continue; 23 } 24 25 for(j=0;j<length1;j++){ 26 if(number==array1[j]) 27 break; 28 } 29 30 if(j==length1){ 31 array1[length1]=number; 32 length1++; 33 } 34 } 35 36 for(i=0;i<length1-1;i++){ 37 for(j=i+1;j<length1;j++){ 38 if(array1[i]>array1[j]){ 39 temp=array1[i]; 40 array1[i]=array1[j]; 41 array1[j]=temp; 42 } 43 } 44 } 45 46 /*for(i=0;i<length1;i++) 47 printf("%d ",array1[i]); 48 printf("\n");*/ 49 50 length2=0; 51 for(i=0;i<n;i++){ 52 scanf("%d",&number); 53 54 if(i==0){ 55 array2[0]=number; 56 length2++; 57 continue; 58 } 59 60 for(j=0;j<length2;j++){ 61 if(number==array2[j]) 62 break; 63 } 64 65 if(j==length2){ 66 array2[length2]=number; 67 length2++; 68 } 69 } 70 71 for(i=0;i<length2-1;i++){ 72 for(j=i+1;j<length2;j++){ 73 if(array2[i]>array2[j]){ 74 temp=array2[i]; 75 array2[i]=array2[j]; 76 array2[j]=temp; 77 } 78 } 79 } 80 81 /*for(i=0;i<length2;i++) 82 printf("%d ",array2[i]); 83 printf("\n");*/ 84 85 if(length1!=length2){ 86 printf("NO\n"); 87 continue; 88 } 89 90 for(i=0;i<length1;i++){ 91 if(array1[i]!=array2[i]){ 92 printf("NO\n"); 93 break; 94 } 95 } 96 97 if(i==length1) 98 printf("YES\n"); 99 100 } 101 102 return 0; 103 }
原文:http://www.cnblogs.com/zqxLonely/p/4079949.html