2016-02-12 50 views
-4

你好,我想知道你是否可以幫我用我的代碼g ++控制檯說:「28 37 C:\ Users \ paul \ Documents \ C++ \ main.cpp [Error] expected';' 「電影」」我的控制檯給我一個錯誤?

#include <iostream> 
#include <string> 
using namespace std; 


int main() 

{ 

int tomscore; 
string movie; 
int metascore; 


cout << "Hello there what movie are you wondering about?" << endl; 
cin >> movie; 

cout << "What is the Rotten Tomato score of the movie in decimal form?"<< endl; 
cin >> tomscore; 

cout << "What is the metascore?" << endl; 
cin >> metascore; 

int average = tomscore+metascore; 

int averageGOD = average/2; 

cout << "The average score for" " " movie " " "was" averageGOD << endl; 
} 
+0

修復此行' cout <<「錯誤信息中」「」movie「」「的平均得分爲」averageGOD << endl;' –

+2

'28 37'意味着錯誤位於或接近第28行,第37列,讓你知道在哪裏可以找到並解決問題 –

回答

6

之前,這是一個錯誤:

cout << "The average score for" " " movie " " "was" averageGOD << endl; 

您需要在您發送到流各項目之間使用<<。此外,它是多餘的把空間在自己的文字:

cout << "The average score for " << movie << " was " << averageGOD << endl; 

如果你試圖輸出引號,則字符串中使用\"

+0

根據錯誤信息?! –

+0

@EdHeal'<<'是需要的,而不是';',因爲錯誤消息提示 –

+0

也許他真的很聰明,並且在其他地方使用字符串「was」,並且不想創建另一個字符串字面值,是「......真正的優化技巧。但也許不是。 – Jts

相關問題