Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

水题一道。两个数,各位数字求和,再相乘。 0MS AC

Posted by zgr0629 at 2009-04-16 22:48:19 on Problem 3673 and last updated at 2009-04-16 22:48:53
123*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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator