50 悬赏关注!!!

P1001 A+B Problem

gsc15759915601 @ 2023-07-18 15:41:56

#include <bits/stdc++.h>
using namespace std;
char s1[3001],s2[3001];
long long n = 1,a[3001] = {0},b[3001] = {0},c[3001] = {0},jw = 0,len1,len2,len3,zc,cd;
int main(){
    cin>>s1>>s2;
    len1 = strlen(s1);
    len2 = strlen(s2);
    for(long long i = 0;i<len1;i++){
        a[len1-i] = s1[i]-'0';
    }
    for(long long i = 0;i<len2;i++){
        b[len2-i] = s2[i]-'0';
    }
    len3 = max(len1,len2);
    for(long long i = 1;i<=len3+1;i++){
        zc = jw+a[i]+b[i];
        c[i] = zc%10;
        jw = zc/10;
    }
    if(zc){
        len3++;
    }
    for(long long i = len3;i>=1;i--){
        cout<<c[i];
    }
    return 0;
}

by apig @ 2023-07-27 17:42:48

这是c还是c++??


by zouzouzi @ 2023-08-08 14:57:52

@gsc15759915601 这样写不香吗?

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b;
    scanf("%lld%lld",&a,&b);
    printf("%lld",a+b);
    return 0;
}

上一页 |