UPC 1016: 幼儿园小朋友们的难题

题目描述

 

幼儿园的小朋友们一直在研究一个问题—— 如何在一个长长的句子中找到最大的那个非负整数(不存在负数)。你很不幸的被他们拖住了,又很不幸的被他们叫去执行这个任务,你非常得不爽! 因为你觉得这么简单的问题简直侮辱了你的智商,所以你决定写一个程序来代劳。

 

输入

     

输入有多组数据。每组输入一个句子(一定包含数字字符,可能包含空格),长度小于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;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值