#include <cstdlib>
#include <iostream>
using namespace std
int main(int argc, char *argv[])
{
int a,b
while(1)
{
cout<<"输入第一个数"<<endl
cin>>a
cout<<"输入第二个数"<<endl
cin>>b
cout<<"比较结果:"<<endl
string rst=(a>=b?(a>b?"大于":"等于"):"小于")
cout<<a<<rst<<b<<endl
}
system("PAUSE")
return EXIT_SUCCESS
}
dev c++还是挺好用的,它的C++扩展库支持还是不错的。
希望对你有帮助!
你if后面跟着的cout没有在括号
里面,if为假只是不输出接着的cout,但{
}里面的会继续输出
#include<iostream>
using
namespace
std
int
main(void)
{
int
a,b,c,max,min
cout<<"请输入要比较的2个数:
"
cin>>a>>b
cout<<"1较大数
2较小数:
"
cin>>c
if
(c==1)
{
if
(a>b)
{
max=a
}
else
max=b
cout<<"所求的为较大数="<<max<<endl
}
if
(c==2)
{
if
(a<b)
{
min=a
}
else
min=b
cout<<"所求的为较小数="<<min<<endl
}
return
0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)