问题标题: 1116//Compile Error:0分

0
0
已解决
褚福磊
褚福磊
新手光能
新手光能

 

#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    int s,d,f,v,y,x;
    cin>>a>>b>>c;
    s=a>b;
    d=a<b;
    f=a==b;
    v=a>=b+c;
    y=a<=b+c;
    x=a!=b;
    cout<<s<<" "<<d<<" "<<f<" "<<v<<" "<y<<" "<<x;
}

3
已采纳
蒋智航
蒋智航
高级天翼
高级天翼

直接cout简洁方便

cout<<(a>b)<<" "<<(a<b)<<" "<<(a==b)<<" "<<(a>=b+c)<<" "<<(a<=b+c)<<" "<<(a!=b);

 

3
3
0
张马润泽
张马润泽
初级光能
初级光能

没加return 0;(有事不加也行啊)

0
黄依成
黄依成
中级天翼
中级天翼

    如果(a>b)    输出<<1<<" ";
    否则       输出<<0<<" ";
    如果(a<b)    输出<<1<<" ";
    否则       输出<<0<<" ";
    如果(a==b)  输出<<1<<" ";
    否则       输出<<0<<" ";
    如果(a>=b+c) 输出<<1<<" ";
    否则       输出<<0<<" ";
    如果(a<=b+c) 输出<<1<<" ";
    否则       输出<<0<<" ";
    如果(a!=b)   输出<<1<<" ";
    否则      输出<<0<<" ";

黄依成在2020-02-07 10:45:32追加了内容

保AC

0
0
邵逸儒
邵逸儒
中级天翼
中级天翼
int a,b,c;
    cin>>a>>b>>c;
    if (a>b)
    {
        cout<<"1"<<" ";
    }else cout<<"0"<<" ";
     if (a<b)
    {
        cout<<"1"<<" ";
    }  else cout<<"0"<<" ";                             
     if (a==b)
    {
        cout<<"1"<<" ";
    }else cout<<"0"<<" ";
     if ( a>=b+c)
    {
        cout<<"1"<<" ";
    }else cout<<"0"<<" ";                                          
     if (a<=b+c)
    {
        cout<<"1"<<" ";
    }else cout<<"0"<<" ";                                               
     if (a!=b)
    {
        cout<<"1"<<" ";
    }else cout<<"0"<<" ";   
     return 0;

 

0
0
朱宇辰
朱宇辰
初级守护
初级守护

代码第14行少打一个字符。改成这样:cout<<s<<" "<<d<<" "<<f<<" "<<v<<" "<y<<" "<<x;

0
周天睿
周天睿
初级光能
初级光能

s,d,f,v,y,x要定义成布尔型,还有return 0;

我要回答