用c语言编写,数据从键盘输入,我是新手,最好帮忙把主函数也写上,多谢了!
第1个回答 2020-01-15
#include<stdio.h>
int main() {
int a[10] = { 7,4,2,1,2,8,1,3,2,3 };
int len = 10;
for (int i = 0; i < len; i++) {
for (int j = i+1; j < len; j++) {
if (a[i] == a[j]) {
for (int k = j; k < len; k++) {
a[k] = a[k + 1];
len--;
}
}
}
}
for (int i = 0; i < len; i++) {
printf("%d ", a[i]);
}
}本回答被网友采纳
int main() {
int a[10] = { 7,4,2,1,2,8,1,3,2,3 };
int len = 10;
for (int i = 0; i < len; i++) {
for (int j = i+1; j < len; j++) {
if (a[i] == a[j]) {
for (int k = j; k < len; k++) {
a[k] = a[k + 1];
len--;
}
}
}
}
for (int i = 0; i < len; i++) {
printf("%d ", a[i]);
}
}本回答被网友采纳