能问下为什么这题绕开换行就没有TLE了吗?谢
查看原帖
能问下为什么这题绕开换行就没有TLE了吗?谢
324480
82Young_UwU楼主2022/4/5 17:31
cin >> shu;
		
if(suan=='+') he+=shu;
else if(suan=='-') he-=shu;
		
suan=cin.get();
if(suan=='\n') break;

这是原来代码while里的内容,全超时了

看了下讨论版第5个的大佬的回复,改成下面这样就过了

cin >> shu;
		
if(suan=='+') he+=shu;
else if(suan=='-') he-=shu;
		
suan=cin.get();
if(suan!='+' and suan!='-') break;

但我还不知道原理是啥,有大佬能给我这个蒟蒻解释下么……

非常感谢!(❤ ω ❤)

2022/4/5 17:31
加载中...