3324 = application order table 1: shifting algorithm to delete the redundant elements

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 int main()
 5 {
 6     int m,i,j,k;
 7     int math[20000];
 8     scanf("%d",&m);
 9     while(m--)
10     {
11         int n;
12         scanf("%d",&n);
13         for(i=0; i<n; i++)
14         {
15             scanf("%d",&math[i]);
16         }
17         for(i=0; i<n-1; i++)
18         {
19             for(j=i+1; j<n; j++)
20             {
21                 if(math[i]!=math[j]);
22                 else
23                 {
24                     for(k=j; k<n-1; k++)
25                     {
26                         math[k]=math[k+1];
27                     }
28                     n--;
29                     j--;
30                 }
31             }
32         }
33         for(i=0; i<n; i++)
34         {
35             if(i!=0)printf(" ");
36             printf("%d",math[i]);
37         }
38         printf("\n");
39     }
40     return 0;
41 }

 

Guess you like

Origin www.cnblogs.com/Angfe/p/11634769.html