本文共 898 字,大约阅读时间需要 2 分钟。
HDU 1002
没谁了。。。 不过,sscanf很重要!!!!!!!!!!!!!!!#include#include #include #include using namespace std;int main(){ char a[20],b[20]; while(scanf("%s%s",a,b)!=EOF) { int t1=0,t2=0; double s1,s2; if(a[0]=='-') t1=1; if(b[0]=='-') t2=1; int la=strlen(a),lb=strlen(b); int l1=0,l2=0; for(int i=0; i ='0'&&a[i]<='9') a[l1++]=a[i]; a[l1]='\0'; for(int i=0; i ='0'&&b[i]<='9') b[l2++]=b[i]; b[l2]='\0'; s1=a[0]-'0'; s2=b[0]-'0'; for(int i=1; i
int main(){ char str1[15],str2[15]; char s1[15],s2[15]; while(~scanf("%s%s",str1,str2)) { int k=0; for(int i=0;str1[i];i++) { if(str1[i]!=',') s1[k++]=str1[i]; } s1[k]=0; k=0; for(int i=0;str2[i];i++) { if(str2[i]!=',') s2[k++]=str2[i]; } s2[k]=0; int a,b; sscanf(s1,"%d",&a); sscanf(s2,"%d",&b); printf("%d\n",a+b); } return 0;}
转载地址:http://fjbci.baihongyu.com/