YYaini @ 2023-05-15 16:54:17
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,a[1001],x,sum;
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
cin>>x;
for(int i=1;i<=n;i++)
{
if(a[i]<x)
sum=i;
}
if(sum==0)
{
cout<<1<<endl;
return 0;
}
else if(sum==n)
{
cout<<n+1<<endl;
return 0;
}
cout<<sum+1<<endl;
return 0;
}
by AutomatiC__ @ 2023-05-15 17:03:40
没有初始化sum
。
by YYaini @ 2023-05-17 16:31:25
@AutomatiC__ 谢谢大佬的解答!