使用单个getchar时要确保后面没有空格(使用快读的情况下),因为快读会读入数据之间空格从而读入错误的数据。 因此可以用 C++复制char ch[3]; scanf("s",ch); if(ch[0]== ...) { ... }