读书人

帮忙看看哪里有有关问题

发布时间: 2012-03-17 19:06:28 作者: rapoo

帮忙看看,哪里有问题
#include<iostream>
using namespace std;
int main()
{
int a,b,t,p;
cout<<"Please input two numbers:"<<endl;
cin>>a>>b;
if(a>b)
{cout<<"a>b:"<<"a="<<a<<","<<"b="<<b<<endl;
t=a;
a=b;
b=t;
cout<<"After exchange,the numbers's order is form the small to big:"<<"a="<<a<<","<<"b="<<b<<endl;
}
else
cout<<"a<=b:"<<"a="<<a<<","<<"b="<<b<<endl;
cout<<"If you want to continue,please press 1 or 0 to quit."<<p<<endl;
cin>>p;
if(p==1)
continue;
}


[解决办法]
else {
cout<<"a<=b:"<<"a="<<a<<","<<"b="<<b<<endl;
cout<<"If you want to continue,please press 1 or 0 to quit."<<p<<endl;
cin>>p;
if(p==1)
continue;
}
[解决办法]

C/C++ code
#include<iostream>using namespace std;int main(){    int a,b,t,p;    cout<<"Please input two numbers:"<<endl;    cin>>a>>b;    if(a>b)    {cout<<"a>b:"<<"a="<<a<<","<<"b="<<b<<endl;    t=a;    a=b;    b=t;    cout<<"After exchange,the numbers's order is form the small to big:"<<"a="<<a<<","<<"b="<<b<<endl;    }    else        cout<<"a<=b:"<<"a="<<a<<","<<"b="<<b<<endl;    cout<<"f (
[解决办法]
#include<iostream>
using namespace std;
int main()
{
int a,b,t,p;

do
{
cout<<"Please input two numbers:"<<endl;
cin>>a>>b;
if(a>b)
{
cout<<"a>b:"<<"a="<<a<<","<<"b="<<b<<endl;
t=a;
a=b;
b=t;
cout<<"After exchange,the numbers's order is form the small to big:"<<"a="<<a<<","<<"b="<<b<<endl;
}
else
{
cout<<"a<=b:"<<"a="<<a<<","<<"b="<<b<<endl;
}
cout<<"If you want to continue,please press 1 or 0 to quit."<<p<<endl;
cin>>p;
}
while(p==1);
return(0);
}

这样才对吧!
不是输入'1'继续 '0'结束吗? 原本的code不管输入什麽,都会结束


[解决办法]
C/C++ code
#include<iostream>using namespace std;int main(){ int a,b,t,p; do {     cout<<"Please input two numbers:"<<endl;     cin>>a>>b;     if(a>b)     {         cout<<"a>b:"<<"a="<<a<<","<<"b="<<b<<endl;         t=a;         a=b;         b=t;         cout<<"After exchange,the numbers's order is form the small to big:"<<"a="<<a<<","<<"b="<<b<<endl;     }     else     {         cout<<"a<=b:"<<"a="<<a<<","<<"b="<<b<<endl;     }     cout<<"If you want to continue,please press 1 or 0 to quit."<<p<<endl;     cin>>p; } while(p==1); return(0);} 

读书人网 >C++

热点推荐