在Python中,我可以执行以下操作:

char_choice = input("What is your character choice? Please enter A, W or   D.")
while char_choice.lower() not in ["a", "w", "d"]:
    char_choice = input("You entered an incorrect character. Please try
    again:")

有没有办法可以在C++中重复第2行?我已经以多种方式尝试了以下方法,但是它没有用,所以我知道自己做错了什么:
    char classificationCode;
    cin >> classificationCode;
    while (classificationCode != "b" || classificationCode != "B" ||     classificationCode != "d" || classificationCode != "D" || classificationCode != "w" || classificationCode != "W");

最佳答案

您正在针对字符串检查字符,是否尝试过

classificationCode != 'b'

09-28 00:56