| ||||||||||
| 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 | |||||||||
Re:why pe????In Reply To:why pe???? Posted by:zwf at 2005-08-04 23:50:56 code:
#include<stdio.h>
int main()
{int i,j,a,b,c[1001],find,A;
while(1)
{
scanf("%d%d",&a,&b);
if (a==0&&b==0) break;
i=1;find=0;
c[1]=a; printf(".");
while(c[i]!=0&&i<=b)
{
A=c[i]*10/b;
c[i+1]=c[i]*10%b;
printf("%d",A);
if((i+1)%50==0) printf("\n");
for(j=1;j<=i;j++)
{
if(c[j]==c[i+1])
{find=1;break;}
}
if(find==1) break;
i++;
}
if(find) printf("\nThe last %d digits repeat forever.\n",(i+1-j));
else printf("\nThis expansion terminates.\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator