改了,但为什么还只有90分呀?????!!!!!

P1001 A+B Problem

ILIKEYSH1314 @ 2024-12-14 16:45:46

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b;
    cin>>a>>b;
    if(a<0&&b<0){
    long long i=0;
    while(i>a){
        i--;
    }
    long long n=0;
    while(n>b){
        n--;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    }
    //a与b都小于0; 
    else if(a>0&&b<0){
    long long i=0;
    while(i<a){
        i++;
    }
    long long n=0;
    while(n>b){
        n--;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    }
    //a大于0,b小于0; 
    else if(a<0&&b>0){
    long long i=0;
    while(i>a){
        i--;
    }
    long long n=0;
    while(n<b){
        n++;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    }
    //a小于0, b大于0; 
    else if(a>0&&b>0){
    long long i=0;
    while(i<a){
        i++;
    }
    long long n=0;
    while(n<b){
        n++;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    }
    //a与b都大于0; 
    else if(a==0&&b>0){
    long long n=0,i=0;
    while(n<b){
    n++;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    }
    //a=0,b大于0; 
    else if(a==0&&b<0){
    long long n=0,i=0;
    while(n>b){
    n--;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    }
    //a=0,b小于0;
    else if(a<0&&b==0){
    long long n=0,i=0;
    while(n>a){
    n--;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    } 
    //a小于0,b=0; 
    else if(a>0&&b==0){
    long long n=0,i=0;
    while(n<a){
    n++;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    } 
    //a大于0,b=0; 
 }

by wuenzi @ 2024-12-23 21:04:09

有问题吧


by yjj13621355890 @ 2024-12-23 21:08:13

哥们儿,搞这么花里胡哨用不着吧!直接

#include<iostream>//包含头文件好吧
using namespace std;//名称空间好吧
int main()
{
    int a,b;//定义好吧
    cin>>a>>b;//读入好吧
    cout<<a+b;//输出好吧
    return 0;//结束好吧
}

不就得了吗好吧


by cjwv @ 2024-12-29 11:19:15

@ILIKEYSH1314


by Rb3f @ 2025-01-04 21:19:14

#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    return 0;
}

没必要太长


上一页 |