```cpp
#include <bits/stdc++.h>
using namespace std;
inline bool isdight(char ch) {
if (ch >= '0' && ch <= '9') {
return true;
}
return false;
}
int read() {
int x = 0, f = 1;
char ch = getchar();
while (!isdight(ch)) {
if (ch == '-') {
f = -1;
}
ch = getchar();
}
while (isdight(ch)) {
x = x * 10 + (ch - '0');
ch = getchar();
}
return x * f;
}
void write(int x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x > 9) {
write(x / 10);
}
putchar(x + '0');
return ;
}
signed main()
{
int ans = 0;
int n = read();
for (int i = 1; i <= n; i++) {
int x = read();
ans += x;
}
write(ans);
return 0;
}
```
rt,同问
by topcsa @ 2024-08-20 17:35:53
我加了`inline`会报错,把`inline`去掉了。
by topcsa @ 2024-08-20 17:37:06
@[topcsa](/user/960206) write 里的 putchar(x+'0') 应该是 putchar(x%10+'0')
by chaotic_ @ 2024-08-20 20:14:02
虽然但是 getchar 太慢了会 T
by chaotic_ @ 2024-08-20 20:15:04
@[chaotic_](/user/1351568) 哦,谢谢,一关
by topcsa @ 2024-08-20 20:33:50