题解 | 明明的随机数
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
#include <stdio.h>
#define INDEX 500
typedef int HASH ;
void initHash(HASH* hash)
{
int count = 0;
char* ptr = hash;
count = INDEX * sizeof(HASH);
while(count--)
{
*ptr=0;
ptr++;
}
}
int main() {
int N;
int buf;
HASH hash[INDEX+1];
initHash(hash);
scanf("%d",&N);
getchar();
while(N--)
{
scanf("%d",&buf);
getchar();
hash[buf] = buf;
}
for(N=0;N<INDEX;N++)
{ if(hash[N] == 0);
else
printf("%d\n",N);//hashN等于N
}
return 0;
}
防御编程
OPPO公司福利 1271人发布