#include "stdafx.h"
int a[] = { 1,2,3,4,5,6,6,5,9,1,2 };
int b[] = {5,6};
int LEN = sizeof(a) / sizeof(a[0]);
void yiwei(int* a,int b) {
for (int i = b;i < LEN ;i++) {
a[i] = a[i + 1];
}
}
int main()
{
for (int i = 0;i < LEN;i++) {
printf("%d\t",a[i] );
}
printf("\n");
for (int i = 0;i < LEN;i++) {
for (int j = i+1;j < LEN;j++) {
if (a[i] == a[j]) {
yiwei(a, j);
LEN--;
}
}
}
for (int i = 0;i < LEN;i++) {
for (int j = 0;j < 2;j++) {
if (a[i] == b[j]) {
yiwei(a, i);
LEN--;
}
}
}
for (int i = 0;i < LEN;i++) {
printf("%d\t", a[i]);
}
printf("\n");
printf("%d", LEN);
getchar();
return 0;
}
时间: 2024-10-11 00:03:22