1144 The Missing Number
作者:互联网
大致题意就是给出一连串的整数(包含正负),找出未出现过的最小正整数。
1 #include<iostream> 2 #include<map> 3 using namespace std; 4 5 int main() { 6 int n,t,ans = 1; 7 map<int,bool> mp; 8 cin>>n; 9 for(int i = 0; i < n; ++i) { 10 scanf("%d",&t); 11 if(t >= 1&&mp[t] == false) { 12 mp[t] = true; 13 if(t == ans) { 14 while(mp[ans]) { 15 ans++; 16 } 17 } 18 } 19 } 20 printf("%d",ans); 21 return 0; 22 }
标签:题意,1144,Missing,int,Number,++,mp,ans,include 来源: https://www.cnblogs.com/keep23456/p/12491378.html