帮我看下这个C++程序如果多次算呀!救命

来源:百度知道 编辑:UC知道 时间:2024/05/28 15:48:02
// 00002.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int x,y;
while ( cin )
{
cout <<"请输入你的数X和Y\n";
cout <<"这样可以让系统为你算出他们的和";
cin>>x>>y;
if(x!=y)
cout<<x*y;
else cout<<"你在算平方吗"<<x*y<<"是这个数吗?";
system("pause");
return 0;
}
}

我用的VS2005
这次加了system("pause")之后那个黑框不会一开始就结束了,但是还是不能多次计算,算了一次之后,在按任意键又没了,气死人
大哥,我说的是让他一直算,不是要算多少次呀,没有办法吗,我QQ421794058,加群一起说30661951

while(cin) 什么意思啊?
改成下面这样吧
那就改成下面这样吧

#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int x,y;
int t=10; //要计算的次数,要几次,自己改
while ( 1)
{
cout <<"请输入你的数X和Y\n";
cout <<"这样可以让系统为你算出他们的和";
cin>>x>>y;
if(x!=y)
cout<<x*y;
else cout<<"你在算平方吗"<<x*y<<"是这个数吗?";
system("pause");
t--;
}
return 0; //放到下面啊 不然第一次就返回了,就结束了啊
}