本文共 563 字,大约阅读时间需要 1 分钟。
#include#include #include using namespace std;const int n_max = 5000 + 5;int n, ans;int sign[n_max];int num[n_max];int main(){ while(~scanf("%d", & n)) { for(int i = 0; i < n; i ++) scanf("%d", & num[i]); memset(sign, 0, sizeof(sign)); for(int i = 0; i < n; i ++) sign[num[i]] = 1; int sum = 0; for(int i = 1; i <= n; i ++) sum += sign[i]; ans = n - sum; printf("%d\n", ans); } return 0;}
:
第一行输入n,之后底下有n个数。这些数中间少了1~n中的几个数。
题解:
水
转载地址:http://wjtpi.baihongyu.com/