标签:style blog io color os sp for 数据 div
1
10
20 40 32 67 40 20 89 300 400 15
8
15 20 32 40 67 89 300 400
1 #include <stdio.h> 2 #include <ctype.h> 3 4 int main(){ 5 int T; 6 int number[200]; 7 int n; 8 int i; 9 int j; 10 int temp; 11 int amount; 12 13 scanf("%d",&T); 14 15 while(T--){ 16 scanf("%d",&n); 17 18 for(i=0;i<n;i++){ 19 scanf("%d",&number[i]); 20 } 21 22 for(i=0;i<n-1;i++){ 23 for(j=i+1;j<n;j++){ 24 if(number[i]>number[j]){ 25 temp=number[i]; 26 number[i]=number[j]; 27 number[j]=temp; 28 } 29 } 30 } 31 32 amount=0; 33 for(i=0;i<n;i++){ 34 if(i==0){ 35 amount++; 36 continue; 37 } 38 39 if(number[i]!=number[i-1]){ 40 amount++; 41 } 42 } 43 printf("%d\n",amount); 44 45 for(i=0;i<n;i++){ 46 if(i==0){ 47 printf("%d",number[0]); 48 continue; 49 } 50 51 if(number[i]!=number[i-1]){ 52 printf(" %d",number[i]); 53 } 54 } 55 printf("\n"); 56 } 57 return 0; 58 }
标签:style blog io color os sp for 数据 div
原文地址:http://www.cnblogs.com/zqxLonely/p/4098576.html