どうしたの、私が取り組んでいるこの巨大なプロジェクトで別の問題が発生しました。
このプロジェクトは学校向けですが、これがすべてではありません。プロジェクトの詳細については、こちらをご覧ください。
したがって、次の形式でユーザーから入力を取得する必要があります。
p 11:45 12:15
p
常に aまたは anで始まりs
、電話での通話が 2 回あります。大きなアイデアは、昼間の分数、夜間の分数などを考慮して携帯電話のプランを比較することです.
現在、入力の取得に問題があります。プログラムを実行するたびに、入力を an で開始しても気にせずs
、さらにデータを待ち続けます。イライラする部分は、それが少し前に機能していたことです。
これが私のコードです:
string c;
string end = "s";
string start = "p";
int temp_start_hour;
int temp_start_min;
int temp_end_hour;
int temp_end_min;
char colon;
do {
cin >> c;
cout << c << endl;
if (c != start && c != end)
{
cout << "ERROR IN INPUT" << endl;
return 1;
}
if (c != end)
{
cin >> temp_start_hour >> colon >> temp_start_min;
cin >> temp_end_hour >> colon >> temp_end_min;
begin_hours[i] = temp_start_hour;
begin_min[i] = temp_start_min;
end_hours[i] = temp_end_hour;
end_min[i] = temp_end_min;
}
i++;
} while (c != end);