链接:http://acm.hdu.edu.cn/showproblem.php?pid=4727
题目大意:在队伍中找出1个报数报错的人的序号。
算是很容易的题。
要注意的:因为这个队伍本来是从其他队伍拉出来的,所以可能这个队伍的第一个人就错了而后面的都对。
没有考虑到第一个是错的情况,所以一开始就错了。how foolish i am....
#include<iostream>
using namespace std;
int a[100005];
int main()
{
int T,n;
scanf("%d",&T);
int time=1;
while(T--)
{
scanf("%d",&n);
int temp=1,b;
temp=1;
for(b=1;b<=n;b++)
{
scanf("%d",&a[b]);
}
for(b=2;b<=n;b++)
{
if(a[b]==a[b-1]+1)
temp=b;
else
break;
}
if(b==n+1)//if b==n+1 ,means the first one is false
temp=0;
printf("Case #%d: %d\n",time++,temp+1);
}
return 0;
}