我第一次去poj,提交了一个数字三角形的题 代码:
#include<iostream>
#include<stack>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<climits>
#include<cstdio>
#include<ctype.h>
using namespace std;
inline void mr(int& theNumberToRead){theNumberToRead = 0; int prn = 1; char c = getchar(); while (!isdigit(c)){if (c == '-')prn = -1;c = getchar();}while (isdigit(c)){ theNumberToRead = 10 * theNumberToRead + c - 48;c = getchar();}theNumberToRead *= prn;}
int n, f[1001][1001], a[1001][1001], ans;
int main()
{
mr(n);
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= i; ++j)
{
mr(a[i][j]);
f[i][j] = max(f[i - 1][j - 1], f[i - 1][j]) + a[i][j];
}
}
for (int i = 1; i <= n; ++i)
ans = max(ans, f[n][i]);
printf("%d", ans);
return 0;
}
结果编译错误,后来把快读改成cin就通过了 有没有懂得解释下怎么会事