【C】#序列中整数去重#
序列中整数去重
https://www.nowcoder.com/practice/6564a2f6e70f4153ad1ffd58b2b28490
#include <stdio.h> int main() { int n, num, cnt = 0; scanf("%d", &n); int arr[n + 1]; for (int i = 0; i < n; i++) { int flag = 0; scanf("%d", &num); for (int j = 0; j <= cnt; j++) { if (arr[j] == num) flag = 1; } if (!flag) { arr[cnt] = num; cnt++; } } for (int k = 0; k < cnt; k++) { printf("%d ", arr[k]); } return 0; }