PAT_A1144
PAT甲级1144.
目录
A1144
题目
样例
输入:
10
5 -25 9 6 1 3 4 2 5 17
输出:
7
思路和坑点
思路:
把出现的数字都进行标记,然后根据标记数组找到题目要求的那个正整数。
AC代码
#include<bits/stdc++.h>
using namespace std;
bool a[100005]={false}; //标记是否出现过
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){ //读取每一个数字,然后把出现过的数字进行标记
int temp;
scanf("%d",&temp);
if(temp<=100000&&temp>0)
a[temp]=true;
}
n=1;
while(1){
if(a[n]==false){ //遍历标记数组,找到那个符合要求的数字
printf("%d",n);
break;
}
n++;
}
return 0;
}