帮忙看看,哪里有有关问题
帮忙看看,哪里有问题
#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;
}
------解决方案--------------------
#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); }