首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

帮忙看看,哪里有有关问题

2012-03-17 
帮忙看看,哪里有问题#includeiostreamusing namespace stdint main(){int a,b,t,pcoutPlease input

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

热点排行