1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| #include<stdio.h> #define N 15 main() { int i,j,k=0,b=[N]; int a[15]={2,3,4,5,5,6,7,8,9,10,10,11,12,12}; for(i=0;i<N;i++) { b[k]=a[i]; for(j=i+1;j<N;j++) if(a[i]!=a[j]) { k++; break; } else break; } for(i=0;i<=k;i++) { if(i%4==0) printf("\n"); printf("%6d",b[i]); } printf("\n"); }
main() { int i,k=0,n=0,b[N]; int a[N]={2,3,4,5,6,7,8,9,10,10,10,11,12,12}; for(i=0;i<N;i++) if(a[i]!=a[i+1]) { b[k]=a[i]; k++; } for(i=0;i<k;i++) { printf("%6d",b[i]); n++; if(n%4==0) putchar("%6d",b[i]); } putchar('n'); }
|