http://acm.hdu.edu.cn/showproblem.php?pid=3787

View Code
#include <iostream>
using namespace std ;
int pow(int a,int b)
{
    int s=1 ;
    for(int i=0;i<b;i++)
        s*=a ;
    return s ;
}
int main()
{
    char a[30],b[30] ;
    int a1,b1 ;
    while(~scanf("%s%s",a,b))
    {
        int cnt=0 ;
        a1=b1=0 ; 
        for(int i=strlen(a)-1;i>=0;i--)
            if(a[i]==',')
                continue ;
            else if(a[i]>='0' && a[i]<='9')
                a1+=(a[i]-'0')*pow(10,cnt++) ;
        if(a[0]=='-')
            a1=(-a1) ;
        cnt=0 ;
        for(int i=strlen(b)-1;i>=0;i--)
            if(b[i]==',')
                continue ;
            else if(b[i]>='0' && b[i]<='9')
                b1+=(b[i]-'0')*pow(10,cnt++) ;
        if(b[0]=='-')
            b1=(-b1) ;
        printf("%d\n",a1+b1) ;
    }
    return 0 ;
}

 

相关文章:

  • 2021-09-01
  • 2021-11-07
  • 2022-01-04
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-21
  • 2021-04-15
  • 2021-05-17
  • 2021-10-07
  • 2021-08-01
  • 2021-08-03
相关资源
相似解决方案