题目描述
幼儿园的小朋友们一直在研究一个问题—— 如何在一个长长的句子中找到最大的那个非负整数(不存在负数)。你很不幸的被他们拖住了,又很不幸的被他们叫去执行这个任务,你非常得不爽! 因为你觉得这么简单的问题简直侮辱了你的智商,所以你决定写一个程序来代劳。
输入
输入有多组数据。每组输入一个句子(一定包含数字字符,可能包含空格),长度小于256,占一行
输出
输出对应有多行,每行输出所找出的最大的那个非负整数
样例输入 Copy
<span style="color:#333333"><span style="color:#333333">&&12345aBsdDkjie64skjd5lk
3*2&&0%%%00B58CD000000b
a000b0000000c000
</span></span>
样例输出 Copy
<span style="color:#333333"><span style="color:#333333">12345
58
0</span></span>
因为学算法学累了,就随便找了点水题。
这可不就是快读么(没负数就很简单)。
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<stack>
#include<map>
#include<list>
#include<vector>
#include<queue>
#include<deque>
#include<set>
#include<functional>
#define pi 3.14159265358979323846264338327950288419716939937510582097494
using namespace std;
#define _for(i, a, b) for(unsigned int i=(a);i<(b);++i)
#define _rep(i, a, b) for(unsigned int i=(a);i<=(b);++i)
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
ll read() {
ll x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (isdigit(c)) x = x * 10 + (c - 48), c = getchar();
return x * f;
}
int main() {
ll ans;
ll x = 0, f = 1;
string s;
while (getline(cin, s)) {
ans = 0;
x = 0;
f = 1;
for (auto &it : s) {
if (isdigit(it)) x = x * 10 + (it - 48);
else {
ans = max(ans, x);
x = 0;
}
}
ans = max(ans, x);
cout << ans << endl;
}
return 0;
}