大佬求助

P1001 A+B Problem

GreenMelon @ 2023-12-31 14:33:04

找不到哪里错了

#include <iostream>
#include <cmath>
using namespace std;
const int MAX=15;

struct AddNum{
    int num1, num2;
};
int add(AddNum num){
    int a[MAX];//用来存储加数的
    int b[MAX]={num.num1, num.num2};//例:._num1 = 1, ._num2=2, b[5]={1, 2}
    for(int i=0;i<2;i++){
        a[i]=b[i];
    }
    return max(a[0], a[1])+min(a[0], a[1]);
} 
AddNum CharToInt(char character1, char character2){
    AddNum Sum;
    Sum.num1=character1-'0';
    Sum.num2=character2-'0';
    return Sum;
}
int main(){
    char Sum1, Sum2;
    AddNum add;
    cin>>Sum1>>Sum2;
    add=CharToInt(Sum1, Sum2);//把字符Sum1与Sum2转换成数字分别复制到add.num1和add.num2 
    cout<<add.num1+add.num2;
    return 0;

}

by GreenMelon @ 2023-12-31 14:34:50

帮大佬写了注释QAQ


by cff_0102 @ 2023-12-31 14:38:30

@I_mAmonkey 你这只能输入一位数啊


by GreenMelon @ 2023-12-31 14:40:06

看到了,本蒟蒻在努力修改


by ink114514 @ 2024-01-02 22:07:40

#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
    return 0;
}

by LRRabcd @ 2024-01-18 11:01:38

好复杂呀


|