题解 | #提取不重复的整数#
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
#include <stdio.h> int main() { int num; char arr[32] = {0}; scanf("%d", &num);//113288 int remain; int n=0; do { remain = num%10; arr[n++] = remain;//882311 } while((num /= 10) > 0); //去重,因为数字只有0-9,所以可以通过标志法去重 char flag[10] = {0}; int i = 0; for (i = 0; i < n; i++) { if (flag[arr[i]] == 0) { printf("%u", arr[i]); flag[arr[i]] = 1; } } }