Quiz League 题解
Quiz League
这道题非常简单,也就红题难度(我才不会告诉你我提交了三次才过)
题目大意:
给定长度为
思路:
循环判断 k 后面第一个为 1 的数,当
注意:
本题需要文件输入输出!!!
#include<bits/stdc++.h>
using namespace std;
int a[1001];
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>a[i];
while(a[k]==0)
{
k++;
if(k>n)//不是>=
k=1;
}
cout<<k;
return 0;
}