Article Directory
Topic restatement
Find 250 (10 points)
The other party didn't want to talk to you, and threw a string of numbers at you... And you must find the tall moving number "250" from this string of numbers.
Input format:
Enter the number of integers whose absolute value does not exceed 1000 in one line, and it is guaranteed that there is at least one "250".
Output format:
The first occurrence of "250" in a line is the first number thrown by the other party (counting starts at 1). The question guarantees that the output number is within the integer range.
Input sample:
888 666 123 -233 250 13 250 -222
Sample output:
5
code
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
string s;
int i=1;
cin>>s;
if(s!="250")
for(i=2;i;i++)
{
cin>>s;
if(s=="250") break;
}
cout<<i<<endl;
}