在输入后面加一个 `getchar`
by Genshineer @ 2023-08-12 21:35:09
@[_Jarvis_](/user/585978)
```
for(int i=1;i<=3;i++){
cin>>a[i];
}
getchar();
for(int i=1;i<=4;i++){
...
```
by Genshineer @ 2023-08-12 21:35:52
@[long_long_integer](/user/191248) 谢谢awa,过了
不过为啥这么写就对了咧,我以前试着这么写过↓
```
for(int i=1;i<=3;i++){
cin>>a[i];
}
sort(a+1,a+4);
s=getchar();
for(int i=1;i<=3;i++){
s=getchar();
//cout<<s;
if(s=='C'){
cout<<a[3]<<' ';
}
.......
}
```
这么写是零,但是光写getchar()就行,why?
by _Jarvis_ @ 2023-08-12 22:42:24
@[_Jarvis_](/user/585978) 这个版本你第二个循环写成了 `for(int i=1;i<=3;i++){`,改成`for(int i=1;i<=4;i++){`就过了
by Genshineer @ 2023-08-12 22:54:06
原来的写法也是没问题的
by Genshineer @ 2023-08-12 22:54:26
是算法问题不是输入问题
by Genshineer @ 2023-08-12 22:54:49
啊所以是getchar的特性?得多读一位??麻烦再问下为什么会测试输出没问题提交不对啊,谢谢qwq
by _Jarvis_ @ 2023-08-12 23:01:14