知识点:
复合类型:
一维数组
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
int arr[n + 1];
int temp[n + 1];
bool flag;
int m = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
for (int i = 0; i < n; i++) {
flag = true;
for (int j = 0; j < m; j++) {
if (arr[i] == temp[j]) {
flag = false;
}
}
if (flag) {
temp[m++] = arr[i];
}
}
for (int i = 0; i < m; i++) {
cout << temp[i] << " ";
}
return 0;
}



京公网安备 11010502036488号