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 |
WA ! Why?#include<stdio.h> #include<stdlib.h> #define MAX 2000 void printans(int a[],int l) { int i,j,m; if(l<=50) for(i=0;i<=l;i++) printf("%d",a[i]); else { m=l/50; for(i=0;i<49;i++) printf("%d",a[i]); printf("\n"); for(i=1;i<m;i++) { for(j=0;j<50;j++) { printf("%d",a[j+i*50]); } printf("\n"); } for(j=m*50-1;j<=l;j++) printf("%d",a[j]); } } int main(void) { int i,j,k,l,num=0; int m,n,d=0; int ans[MAX]={0},a[MAX]={0},b[MAX][2]={0}; while(!scanf("%d %d",&m,&n),m||n) { b[num][0]=m;b[num++][1]=n;} for(;d<num;d++) { m=b[d][0];n=b[d][1]; j=1; a[0]=m; for(i=0;i<n;) { ans[i]=(m*10)/n; m=(m*10)%n; a[j++]=m; if(m==0) { printf("."); printans(ans,i); printf("\nThis expansion terminates.\n"); break; } else for(k=0;k<j-1;k++) if(m==a[k]) { printf("."); printans(ans,i); printf("\nThe last %d digits repeat forever.\n",j-k-1); goto loop; } i++; } loop:; } 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