| ||||||||||
| 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 | |||||||||
为什么总是在发问后自己解答?In Reply To:为什么!为什么PE! Posted by:Manio at 2006-02-16 22:00:32 正解:
main()
{
int a ,b ,yushu[1200] ,r ,i ,j;
int find;
scanf("%d%d",&a,&b);
while( a != 0 && b != 0)
{
yushu[0] = a;
printf(".");
i = 1;
find = 0;
while(1)
{
r = yushu[i-1]*10/b;
yushu[i] = yushu[i-1]*10%b;
printf("%d",r);
if(yushu[i]==0)
{
find = 2;
break;
}
for( j = 0 ; j < i ; j++)
{
if(yushu[j]==yushu[i])
{
find = 1;
break;
}
}
if(find==1 || find==2)break;
if( (i==49) || ( (i > 51) && ((i+1)%50==0) ) )printf("\n"); /*关键是这句!可以看出,第一行只有49个数字(因为包括了“.”),而第二行以后就要有50个*/
i++;
}/*inside while*/
if(find==1)
{
printf("\nThe last %d digits repeat forever.\n",i-j);
}else{
printf("\nThis expansion terminates.\n");
}
scanf("%d%d",&a,&b);
}/*while*/
}/*main*/
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator