Algorithm training array sorting de-heavy time limit: 1.0s memory limit: 512.0MBThe problem description enters a sequence of 10 integers that requires ascending sorting and removes duplicate elements. Enter a format of 10 integers. Output format multiple lines of output, one element per line. Example input 2 2 3 3 1 1 5 5 5 5 Sample Output 1
2
3
5
1#include <stdio.h>2 intMain () {3 inta[Ten];4 for(intI=0;i<Ten; i++){5scanf"%d",&a[i]);6 }7 /*Bubbling Ascending*/8 for(intI=0; i<Ten-1; i++){9 for(intj=0; j<Ten-1-I.; J + +){Ten if(a[j]>a[j+1]){ One intt =A[j]; AA[J] = a[j+1]; -a[j+1] =T; - } the } - } - intindex=1;// Subscript - intb[Ten];//An array that holds non-repeating elements +b[0] = a[0]; - for(intI=1;i<Ten; i++){ + if(A[i]! = a[i-1]){//if the currently traversed element is not equal to the previous element Ab[index++] = A[i];//save it to B. at } - } - for(intI=0; i<index;i++){ -printf"%d\n", B[i]); - } -}
C language · Array sort de-weight