题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
#include <stdio.h> const M = 1001; //良好的编程习惯 int main() { int num[M] = {0}; //散列数组 int n = 0; int i = 0; int count = 0; int tag = 0; //记录用于输出的元素数量 scanf("%d",&count); while(count--){ //读入数据 scanf("%d",&n); num[n] = n; } while(i<M){ if(num[i]!=0){ ++i; ++tag; }else{ ++i; } } i = 0; while(tag){ if(num[i]!=0){ printf("%d\n",num[i++]); --tag; }else{ ++i; } } }#刷题记录#