题解 | #序列中整数去重#
序列中整数去重
https://www.nowcoder.com/practice/6564a2f6e70f4153ad1ffd58b2b28490
#include <stdio.h> int main() { int n, a[1000] = {}; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); //立即对a[i]进行查重 for (int j = 0; j < i; j++) { if (i != 0 && a[j] == a[i]) a[i] = 0; } } for (int i = 0; i < n; i++) { if (a[i] != 0) printf("%d ", a[i]); } return 0; }