167 条题解

  • -1
    @ 2025-1-24 11:59:01

    文言文

    由【键盘】入之甲、乙二整形元素。
    以操作符【+】计算甲、乙之和。
    存入另一整形元素丙。书之。
    

    伪代码(PQ)

    set keyboard as stdin
    set screen as stdout
    input int1024 a b
    c=a(operator +)b
    output c as int1024
    

    伪代码(XD20)
    这个在XD22中也可运行

    function main
    begin.
    stdin a
    stdin b
    stdout a+b
    end.
    

    伪代码(XD22)

    select keyboard as stdin
    select screen as stdout
    gnu -O2 -Wall
    function main
    begin.
    stdin a
    stdin b
    stdout a+b
    end.
    
    

    伪代码(Z)

    select keyboard as input
    select screen as output
    select windows11 as system
    select Z22 as language
    select ZS22 as compiler
    begin.
    read a
    read b
    write a+b
    end.
    flush.
    

    Pascal

    var a, b: longint;
    begin
        readln(a,b);
        writeln(a+b);
    end.
    

    C++

    #include<bits/stdc++.h>
    using namespace std;
    int fu=1,f=1,a,b,c=0;
    int main(){
        cin>>a>>b;
        if(a<0&&b>0)fu=2;
        if(a>0&&b<0)fu=3;
        if(a<0&&b<0)f=-1;
        if(a==0){cout<<b;return 0;}
        if(b==0){cout<<a;return 0;} 
        a=abs(a);
        b=abs(b);
        if(a>b&&fu==3)f=1;
        if(b>a&&fu==3)f=-1;
        if(b>a&&fu==2)f=1;
        if(b<a&&fu==2)f=-1;
        if(fu==1)c=a+b;
        if(fu>1)c=max(a,b)-min(a,b);
        c*=f;
        cout<<c;
        return 0;
    }
    

    信息

    ID
    56
    时间
    1000ms
    内存
    1024MiB
    难度
    1
    标签
    递交数
    9766
    已通过
    4405
    上传者