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 |
不知道为什么错。。。。。。。。。。谁能帮我看看阿..., #include<stdio.h> #include<string.h> char a[50]; char b[50]; char res[100]; void multiply(); int main() { scanf("%s%s",&a,&b); multiply(); printf("%s\n",res); return 0; } void multiply() { int len1=strlen(a); int len2=strlen(b); int i,j,mid,len,t; char temp; int up=0; mid=(len1+1)/2; for(i=0;i<mid;i++) { temp=a[i];a[i]=a[len1-1-i];a[len1-1-i]=temp; } mid=(len2+1)/2; for(i=0;i<mid;i++) { temp=b[i];b[i]=b[len2-1-i];b[len2-1-i]=temp; } for(i=0;i<len1;i++) { for(j=0;j<len2;j++) { t=(a[i]-'0')*(b[j]-'0')+up; if(res[i+j]=='\0') t+=(int)res[i+j]; else t+=(int)(res[i+j]-'0'); if(t>9) up=temp/10; else up=0; res[i+j]='0'+t%10; } if(up!=0) { res[i+j]=up+'0'; up=0; } } len=strlen(res); mid=(len+1)/2; for(i=0;i<mid;i++) { temp=res[i];res[i]=res[len-1-i];res[len-1-i]=temp; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator