前提:输入的是一个字符,如’C’ 错误 char x = 0;//或者int x = 0 scanf("%d", &x); //或cin >> x; 正确 char x = 0;//或者int x = 0; scanf("%c", &x); //或cin >> x;