Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:为什么还是错的呢?(附程序如下)(help!!!!!!!!)

Posted by dhm at 2005-05-23 22:17:35 on Problem 1001
In Reply To:为什么还是错的呢?(附程序如下)(help!!!!!!!!) Posted by:hujk2008 at 2004-06-19 17:49:24
> #include<stdio.h>
> #include<math.h>
> int fun(int a,int k,int n)
> { 
> 	long temp1,temp2;
>     int b[150]={0};      
>     int i,j; 
>     k=k*n; 
>     b[149]=1;    
>     for(i=0;i<n;i++)
> 	{ 
> 		temp2=0;
>         for(j=149;j>=0;j--)
>       { 
> 			temp1=b[j]*a+temp2;   
>             b[j]=temp1%10;         
>             temp2=(int)(temp1/10);
>        }
> 	}
>      i=0;
>      while(b[i]==0&&i<=149-k) i++; 
>      while(i<=149-k)
> 	    printf("%d",b[i++]); 
> 	 if(k==0)
> 	 {printf("\n");return 1;}
>      printf(".");
>      while(i<=149)
>         printf("%d",b[i++]);
>       printf("\n");
> 	  return 1;
> }
> 
> int main()
> {
> 	int n,i,k,j;
> 	char a[10],ab[10];
> 	int b;
> loop:	while(1)
> 		{
> 			for(i=0;i<9;i++)
> 			{
> 				a[i]='\0';
> 				ab[i]='\0';
> 			}
> 		gets(ab);k=0;n=0;
> 		for(i=0;i<6;i++)
> 		{
> 			if(ab[i]!=' ')
> 				a[k++]=ab[i];
> 		}
> 		a[k]='\0';
> 		if(ab[7]!=' ')n=ab[7]-'0';
> 		if(ab[8]!=' '&&ab[8]!='\0')n=n*10+ab[8]-'0';
> 		b=0;k=0;i=0;
> 		for(i=9;i>-1;i--)
> 		{
> 			if(a[i]=='\0')continue;
> 			if(a[i]=='0')
> 		    	a[i]='\0';
> 			if(a[i]>0)
> 				break;
> 		}
> 		for(k=0;k<i;k++)
> 			if(a[k]=='.')
> 				break;
> 		k=i-k;
> 		for(j=0;j<=i;j++)
> 			if(a[j]!='.')
> 				b=b*10+a[j]-'0';
> 		if(b==0)
> 			{
> 				printf("0\n");
> 				goto loop;
> 			}
> 	     fun(b,k,n);
> 	}
> 	return 1;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator