如果使用scanf()进行字符读入操作,需要注意由于题目特殊的测评环境,在一行的最后会分别有一个\n和一个\r,即需要用2个getchar().
scanf()
\n
\r
getchar()
参考该大佬的题解。