高手帮帮忙,怎样让编写的程序窗口不要关闭~~
来源:百度知道 编辑:UC知道 时间:2024/05/31 19:46:14
代码如下,用DEV-C编写,但是一输入值,DOS窗口便关闭了~~~高手有没有办法让窗口保持~~谢谢!!
#include<iostream>
using namespace std;
int main()
{int money;
cout<<"hao much money?";cin>>money;
if (money<1000)
cout<<"so little money you have.\n";
else
cout<<"you have so much money!\n" ;
return 0;
}
#include<iostream>
using namespace std;
int main()
{int money;
cout<<"hao much money?";cin>>money;
if (money<1000)
cout<<"so little money you have.\n";
else
cout<<"you have so much money!\n" ;
return 0;
}
就是等待输入,在main的最后,return之前,放置下列任何一个。可以有多个方法:
1、getchar()函数
#include<stdio.h>
2、getch()函数
#include<conio.h>
3、system("pause");
#include<windows.h>
让程序等待输入
scanf("%d",i);
什么的
在return 0前面加上一句system("pause");
#include<iostream>
#include <windows.h>
using namespace std;
int main()
{
int money;
cout << "how much money?";
cin >> money;
if (money < 1000)
cout << "so little money you have.\n";
else
cout << "you have so much money!\n" ;
system("pause");
return 0;
}