#include <stdio.h>
int main(int argc, const char * argv[]) {
int arr[9]={4,2,4,6,1,2,4,7,8};
int arr2[9]={0},count=0;
int isSame=0;
arr2[0]=arr[0];
for (int i=1; i<sizeof(arr)/sizeof(int); i++) {
isSame=0;
for (int j=0; j<=count; j++) {
if (arr[i]==arr[j]) {
isSame=1;
}
}
if (isSame == 0) {
count++;
arr2[count]=arr[i];
}
}
for (int i = 0; i<=count; i++) {
printf("%d ",arr2[i]);
}
return 0;
}
|
|