<分区>
我最近决定开始学习 C++,一开始我遇到了控制台在输出后立即关闭的问题,这可以通过添加 System("pause") 来解决,现在我有一个程序两个输入,在第一次输入后控制台关闭,没有显示任何输出,我无法用系统(“暂停”)修复它。
#include <iostream>
using namespace std;
int main(){
char name[50];
int age;
cout << "Please enter your name? ";
cin >> name;
cout << endl << "Okay, how old are you ? ";
cin >> age;
cout << "Nice to meet you, " << name << "!" endl;
if (age < 10) cout << "Oh, you're quite young aren't you!" << endl; else
if (age < 20) cout << "Embrace your teens they won't last long!" << endl else
if (age < 40) cout << "Ah, I see you're still in your prime" << endl else
if (age < 60) cout << "That's nice" << endl;
return 0;
}