121另类乘法 For example, the product 123*45 is equal to 1*4 + 1*5 + 2*4 + 2*5 + 3*4 + 3*5 = 54.

#include<stdio.h>
int main()
{
 int a,b,a1,b1,b0,n,i;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
   int s=0;
   scanf("%d%d",&a,&b);
   b0=b;
 while(a)
 {
  a1=a%10;
  a/=10;
  b=b0;
  while(b)
  {
   b1=b%10;
   b/=10;
   s=s+a1*b1;
  }
  
 }
 printf("%d\n",s);
 }return 0;
}

posted @ 2013-06-16 16:25  融雪残阳  阅读(245)  评论(0编辑  收藏  举报