C语言如何求一维数组的不重复数据个数 下面是C语言求一维数组的不重复数据个数的实现代码,供参照:
C语言问题:查找重复的数据 int array_n[N];int find_duplex(void){int i,j;for(i=0;i;i+)for(j=i+1;j;j+)if(array_n[i]=array_n[j]){printf(\"the duplex:%d\\n\",array_n[i]);return i+1;}}
c语言删除重复数据 /*排序前:2 6 5 1 1 9 7 6 6 6排序后:9 7 6 6 6 6 5 2 1 1删除相同元素后:9 7 6 5 2 1Press any key to continueincludeincludeincludeint const N=10;void Sort(int a[],int n){int i,j,k,t;for(i=0;i;i){k=i;for(j=i+1;j;j){if(a[k][j])k=j;}if(i。k){t=a[i];a[i]=a[k];a[k]=t;}}}int DelSame(int a[],int n){int i,j,k;for(i=0;i;i){for(j=i+1;j;j){if(a[i]=a[j]){for(k=j;k;k)a[k]=a[k+1];n;j;}}}return n;}void Show(int a[],int n){int i;for(i=0;i;i)printf(\"%d\",a[i]);printf(\"\\n\");}int main(){int a[10],i,n;srand(time(0));for(i=0;i;i+)a[i]=rand()%10;printf(\"排序前:\\n\");Show(a,N);Sort(a,N);printf(\"排序后:\\n\");Show(a,N);n=DelSame(a,N);printf(\"删除相同元素后:\\n\");Show(a,n);return 0;}