1 #include<stdio.h> 2 int fun(char *p,char *p1) 3 { 4 char *ch,*ch1; 5 int sum=0,temp=0; 6 ch=p,ch1=p1; 7 while(*ch) //抓取每個位置上的字符轉換成數字 8 { 9 temp=temp*10+(*ch-'0'); //每次累加一個數字后乘十移位 10 ch++; 11 } 12 sum+=temp; //將第一個字符串的數先累加到sum 13 temp=0; //歸零進行下一次運算 14 while(*ch1) 15 { 16 temp=temp*10+(*ch1-'0'); 17 ch1++; 18 } 19 return (sum+=temp); 20 } 21 int main() 22 { 23 char a[100],b[100]; 24 gets(a); 25 gets(b); 26 printf("%d",fun(a,b)); 27 return 0; 28 }