correct = 0;
    cout << "You entered " << years << ".\nIs that correct? (Y/N) \n";
    cin >> yesNo;
    if (yesNo == 'y' || 'Y')
         correct ++;
} while (correct != 1);
    cout << "good! " << correct << endl;
return 0;

}
我希望它只对正确的int ++ ++(如果是)否= y或Y,如果不是,我希望它循环回到顶部(看不见)

最佳答案

我想你的问题出在

if (yesNo == 'y' || 'Y')

它应该是
if (yesNo == 'y' || yesNo== 'Y')

10-05 18:15