本文主要是介绍UVa 12640 Largest Sum Game (water ver.),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
12640 - Largest Sum Game
Time limit: 1.000 seconds
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=602&page=show_problem&problem=4388
题目:http://uva.onlinejudge.org/external/126/12640.pdf
主要是读取数据怎么处理。
完整代码:
/*0.055s*/#include<cstdio>
#include<algorithm>
using namespace std;int main(void)
{char ch;int x, maxn, sum, exit;while (true){maxn = sum = 0;while (true){exit = scanf("%d%c", &x, &ch);if (exit == -1) return 0;sum += x;if (sum <= 0) sum = 0;else maxn = max(maxn, sum);if (ch == '\n' || exit == 1){printf("%d\n", maxn);break;}}}return 0;
}
这篇关于UVa 12640 Largest Sum Game (water ver.)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!