2017-08-27 85 views
-4

我写了下面的程序,并没有正确打印。输入速率和小时数后,控制台显示为关闭。程序在打印输出前输入后退出

#include "stdafx.h" 
#include <iostream> 
using namespace std; 
int main() 
{ 
    double hours, rate, pay; 
    // Get the number of hours worked. 
    cout << "How many hours did you work? "; 
    cin >> hours; 
    // Get the hourly pay rate. 
    cout << "How much do you get paid per hour? "; 
    cin >> rate; 
    // Calculate the pay. 
    pay = hours * rate; 
    // Display the pay. 
    cout << "You have earned $" << pay << endl; 
    return 0; 
} 
+0

“不调试”是什么意思? – Fureeish

+0

这个程序运行,编译,并可以步入正常状态。我不明白你的问题是什么。 –

+0

对我来说,它只是退出后,你放了几个小时,我不明白我认为它与视觉工作室的配置问题? – panzer67

回答

0

该程序打印结果并退出。这是正常的行为。您可以在return语句之前添加system("pause");以延迟关闭控制台。