1
好吧,我非常新 - 嘗試除外。我不知道我想要做什麼是可能的,但我想我會要求輸入。使用異常來將用戶輸入存儲爲雙精度或字符串
我的程序應該平均x的用戶輸入量,直到他/她輸入q。
這是給我最多問題的功能。
矢量USER_INPUT(){
vector<double> scores;
string user_command;
do{
double user_input;
cout << "Enter the scores to be averaged (range 0-100) or enter q to quit: " << endl;
cin >> user_command;
if (is_number(user_command))
{
user_input = atof(user_command.c_str());
if (user_input < 0 || user_input > 100)
cout << "This is not within range!" << endl;
else{
scores.push_back(user_input);}
}
}
while (user_command != "q" && user_command != "Q");
return scores;
}
我需要這個節目爲什麼不會編譯一些見解。任何幫助,將不勝感激
您需要先解決您的語法問題。你在第一個'cout <<'行的結尾缺少';',你錯過了一些大括號。 – Barmar 2014-10-11 01:52:02
您也錯過了'try'語句的'catch'塊。 – Barmar 2014-10-11 01:53:00
這個例子有大約一百萬個錯誤,直到例子修復。 – 2014-10-11 01:56:08