| ||||||||||
| 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 | |||||||||
水过50.贴个代码。#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int anwser[200]={0},i,j,z,aa[200]={0},bb[200]={0},cc[200][200]={0},lena,lenb;
char a[1000],b[1000];
scanf("%s%s",&a,&b);
lena=strlen(a);
lenb=strlen(b);
for(i=0;i<lena;i++)//字符串逆置保存在整型数组
aa[lena-1-i]=(int)a[i]-48;
for(i=0;i<lenb;i++)
bb[lenb-1-i]=(int)b[i]-48;
for(i=0;i<200;i++){//bb中每一位都乘以aa然后保存在二维数组cc 中
z=i;
for(j=0;j<200;j++){
cc[i][j+z]+=aa[i]*bb[j];
cc[i][j+z+1]=cc[i][j+z]/10;//进位
cc[i][j+z]=cc[i][j+z]%10;
}
}
for(i=0;i<100;i++){//把cc中属于同一位的结果加在一起保存在anwser数组中
for(j=0;j<100;j++){
anwser[i]+=cc[j][i];
}
anwser[i+1]=anwser[i]/10;
anwser[i]=anwser[i]%10;
}
i=199;//从最高位向下找到第一位不为0的
while(anwser[i]==0){
i--;
}
for(j=i;j>=0;j--)//输出
printf("%d",anwser[j]);
system("PAUSE");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator