各位大神我的代码哪里错了?
  • 板块P1001 A+B Problem
  • 楼主freyyerf
  • 当前回复23
  • 已保存回复23
  • 发布时间2022/2/15 13:49
  • 上次更新2023/10/28 08:29:02
查看原帖
各位大神我的代码哪里错了?
675596
freyyerf楼主2022/2/15 13:49
#include <iostream>
using namespace std;
int plus(int x,int y){
  int z,q,a;
  if(x<0){
    if(y>0){
      y=y-(0-x);
      z=y;
    }else if(y<0){
      q=-x;
      a=-y;
      z=plus(q,a);
    }else{
       z=x;
    }
  }else if(x>0){
    if(y>0){
      z=x+y;
    }else if(y<0){
      x=x-(0-y);
      z=x;
    }else{
       z=x;
    }
  }else{
    if(y>0){
      z=y
    }else if(y<0){
      z=y
    }else{
      z=y;
    }
  
  }
  return z;
}
int main(){
  int a,b,ans;
  cin>>a>>b;
  ans=plus(a,b);
  cout<<plus;
  return 0;
}

提交后报错了......

2022/2/15 13:49
加载中...