数组中重复的数
作者:互联网
#include<stdio.h>
#include<string.h>
void getnum(int a[],int size);
int main(void)
{
int n = 0;
int num[] = { 1,3,5,7,8,6,7,4,3 };
n = sizeof(num)/sizeof(int);
getnum(num,n);
system(“pause”);
return 0;
}
void getnum(int a[],int size)
{
int i = 0, j = 0;
for (i = 0; i < size - 1; i++)
{
for (j = i + 1; j < size; j++)
{
if (a[i] - a[j] == 0)//利用相等的数为0的特点
{
printf("数组中重复的数字为a[%d]=a[%d]=%d\n",i,j,a[i]);
}
}
}
}
标签:重复,void,++,int,getnum,num,数组,size 来源: https://blog.csdn.net/qq_38158479/article/details/101477833