Visual Studio程序在cmd提示输入窗口期间存在

时间:2014-08-09 22:33:42

标签: c++ visual-studio-2012

输入cin>>后,我在Visual Studios中执行此代码在完成之前,tomatometer将程序退出。任何帮助将不胜感激?

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

int main() {
    // Get the name of the Movie
    string movie = "";
    cout << "What is the name if the movie ?\n";
    getline(cin, movie);

    // Get the Metascore
    double metascore = 0;
    cout << "What is the Metascore rating " << movie << " ?\n";
    cin >> metascore;

    // Get the Tomatometer score
    double tomatometer = 0;
    cout << "What is the Tomatoscore rating " << movie << "?\n";
    cin >> tomatometer;

    // Calculate the average
    double avg = (metascore + tomatometer) / 2.0;

    // Rescale the average
    double rescaleScore = avg / 10;
    cout << "Our average rating on a 10 point scale for " << movie
         << " is                 " << rescaleScore
         << "."; // Display the results of the calculation
    return 0;
}

0 个答案:

没有答案