您好,我想知道您是否可以帮助我使用我的代码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;
}
Run Code Online (Sandbox Code Playgroud)
这是一个错误:
Run Code Online (Sandbox Code Playgroud)cout << "The average score for" " " movie " " "was" averageGOD << endl;
您需要<<在要发送到流的每个项目之间使用.将空格放在自己的文字中也是多余的:
cout << "The average score for " << movie << " was " << averageGOD << endl;
Run Code Online (Sandbox Code Playgroud)
如果您尝试输出引号,则\"在字符串中使用.