| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
水题一道。两个数,各位数字求和,再相乘。 0MS AC123*45 = 1*4 + 1*5 + 2*4 + 2*5 + 3*4 + 3*5
= (1+2+3)*4 + (1+2+3)*5
= (1+2+3)*(4+5)
囧。。。。
#include <stdio.h>
#include <string.h>
int main()
{
char a[15],b[15];
int la,lb,i,sum;
scanf("%s %s",a,b);
la=strlen(a);a[0]-='0';
lb=strlen(b);b[0]-='0';
for(i=1;i<la;i++)
a[0]+=a[i]-'0';
for(i=1;i<lb;i++)
b[0]+=b[i]-'0';
sum=a[0]*b[0];
printf("%d",sum);
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator