R浩轩泽Anmicius @ 2019-10-10 17:40:38
没想到有一天我又会死在入门里
不知道这段代码和快读有没有什么关系(蒟蒻没学过快读),但它没输出 大佬们请指教!!
#include<iostream>
using namespace std;
char c;
bool f;
int n;
int main()
{
cin>>c;
n=0;
if(c=='-')f=true;
else n+=c-'0';
while(cin>>c&&c!='\n')
n=n+10*(c-'0');
if(f)cout<<'-';
cout<<n<<endl;
return 0;
}
教练:“快初赛了你还在入门”
by saxiy @ 2019-10-10 17:57:53
随手码的快读板子
template <typename T> read(T &x) {
x = 0; register char c(getchar()); bool f = 0;
for(;!isdigit(c);c = getchar()) if(c == '-') f = 1;
for(; isdigit(c);c = getchar())
x = (x << 3) + (x << 1) + (c ^ 48);
if(f) x = -x;
}
by saxiy @ 2019-10-10 17:59:33
@Jessie12138 应该是
n=10*n+(c-'0');
by saxiy @ 2019-10-10 18:00:06
可以参考秦九韶算法。
by R浩轩泽Anmicius @ 2019-10-11 17:08:04
@saxiy 蒟蒻瞅瞅