2016-02-12 53 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