c++为什么我加了getchar和return还要自动关闭程序
#include<iostream>usingnamespacestd;intmain(){inta,b,result;cout<<"pleaseinputtwonumb...
#include <iostream>
using namespace std;
int main()
{
int a, b, result;
cout << "please input two numbers";
cin >> a >> b;
result = 3 * a - 2 * b + 1;
cout << "result is " << result;
getchar();
return 0;
} 展开
using namespace std;
int main()
{
int a, b, result;
cout << "please input two numbers";
cin >> a >> b;
result = 3 * a - 2 * b + 1;
cout << "result is " << result;
getchar();
return 0;
} 展开
2个回答
展开全部
#include <iostream>
using namespace std;
int main()
{
int a, b, result;
cout << "please input two numbers";
cin >> a >> b;
getchar(); //cin之后加一个Getchar()就好了,不然,回车会被保留在缓存中,然后被最后的getchar()所接收
result = 3 * a - 2 * b + 1;
cout << "result is " << result;
getchar();
return 0;
}
using namespace std;
int main()
{
int a, b, result;
cout << "please input two numbers";
cin >> a >> b;
getchar(); //cin之后加一个Getchar()就好了,不然,回车会被保留在缓存中,然后被最后的getchar()所接收
result = 3 * a - 2 * b + 1;
cout << "result is " << result;
getchar();
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询