Title Description:
The other person doesn't want to talk to you and throws a bunch of numbers at you ... And you have to find the "250" on this big moving number from this string of numbers.
input Format:
Enter an integer in a row that does not know how many absolute values do not exceed 1000, which guarantees that at least one "250" exists.
output format: The
first occurrence of "250" in a row is the number that the opponent throws (counting starts from 1). The title guarantees that the number of outputs is within the integral type range.
Input Example:
888 666 123-233 250-222
Output Sample:
5
I don't know how many of the questions. That's what you have to do with the get string simulation, and then start with the first one, if it's not a space
ans=ans*10+a[i]-' 0 ';
If it is a space, this number is over, judging whether it is 250
if (a[i]== ') {
//cout<< " " <<ans<<endl;
count++;
if (ans==250) {
answer=count;
flag=0;
}
ans=0;
}
That's probably what it means.
The complete code is as follows:
#include <cstdio> #include <cstdlib> #include <cmath> #include <cstring > #include <iostream> #include <algorithm> #include <queue> #include <map> #include <stack
> #include <set> using namespace std;
typedef long Long LL;
typedef unsigned long long ull;
Char a[1000000];
int main () {Ios::sync_with_stdio (false);
Gets (a);
ll Len=strlen (a);
ll Ans=0;
ll count=0;
ll Answer=1;
ll Flag=1;
for (ll i=0;i<len&&flag;i++) {if (a[i]== ') {//cout<< "" <<ans<<endl;
count++;
if (ans==250) {answer=count;
flag=0;
} ans=0;
} else{ans=ans*10+a[i]-' 0 ';
}} if (ans==250) Answer=++count;
cout<<answer<<endl;
return 0; }