-2
私は、クレーマーのルールと行列についてプログラムを作成しています。そしてどこかで、私はあなたが「はい」または「いいえ」を入力する必要があるこの問題を抱えています。そして私が他の言葉(例えば笑)をタイプしたら、それはelse if文に行きません。回答を「はい/いいえ」に限定するにはどうすればよいですか?C++ If/else ifステートメント
cout << "There! you have now your first equation! is it " << a << "x+" << b << "y=" << e << "? Is it? Yes/No"<<endl;
cin >> z;
if (z== "No")
{
while (z== "No")
{
cout << "what is the value of x?"<<endl;
cin >> a;
cout << "\n"<<endl;
cout << "what is the value of y?"<<endl;
cin >> b;
cout << "\n"<<endl;
cout << "what is the value of answer?"<<endl;
cin >> e;
cout << "\n"<<endl;
cout << "There! you have corrected your first equation! is it " << a << "x+" << b << "y=" << e << "? Is it? Yes/No"<<endl;
cin >> z;
}
}
else if (z== "Yes")
{
cout << "We will now proceed!"<<endl;
}
私はコードブロックdo-while文をよく読んで
入力を受け入れながらあなたは、入力値を制御することはできません。最初に入力を受け入れる必要がありますし、受け入れられた入力が正しいかどうかの条件を確認することができます。間違った入力に対して警告を生成することができます。 – Raman
'z'の種類は何ですか? –