萌新做题,以下为本人拙见,若某位高人另有高招,还望分享。(VS2013)
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define N 10
void main(void)
{
int i, j, k=1,Flag;
int a[N], b[N];
printf("请输入%d个整数:\n", N);
for (i = 0; i < N; i++)
scanf("%d", &a[i]);
b[0] = a[0];
for (i = 1; i < N; i++)
{
Flag = 1;
for (j = 0; j < i; j++)
if (a[j] == a[i])
{
Flag = 0;
break;
}
if (Flag)
{
b[k] = a[i];
k++;
}
}
printf("删除重复数字后的结果:\n");
for (i = 0; i < k; i++)
printf("%d ", b[i]);
printf("\n");
}
测试: