hdu 3787(atoi() char转int)

#include<iostream>
#include<stdlib.h>
using namespace std;

const int maxn = 20;
char a[maxn], b[maxn];
char c[maxn];

int toint(char s[]){
int j = 0;
for(int i=0; i<strlen(s); i++){
if(s[i] == ',')
continue;
c[j++] = s[i];
}
c[j] = '\0';
return atoi(c);
}

int main(){
while(scanf("%s%s", a, b) == 2){
int i = toint(a);
int j = toint(b);
cout<<i + j<<endl;
}
return 0;
}

posted @ 2014-01-22 18:52  静坐观雨  阅读(182)  评论(0编辑  收藏  举报