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

没有纯整数的,前面必定是带小数点的实数 (附个0ms代码,慎入),

Posted by yggzxwj at 2012-11-25 16:52:29 on Problem 1001
乱的很,凑合看吧
#include <stdio.h>
int main()
{
   char S[7];
   int a,b,c,shu[100],xsd,n,bs,q,bj,flag,ll,l;//c是幂数 XSD是小数点位置,bs是本身 
   while(scanf("%s %d",&S,&c)!=EOF)//输入 
   { n=0;
     bs=0;
     bj=0;
     flag=0;
     ll=0;
     for(a=0;a<100;a++)
     {
    	shu[a]=0;
     }
   	 for(a=0;a<6;a++)
   	 {  b=S[a]-48;
	   	if(b<0)
	   	{
	   		xsd=5-a;
	   	}
	   	else
	   	{  
		   shu[95+n]=b;
		   n++;
		   for(q=5-n;q>0;q--)
	   	   {b=b*10;
	   	   }
	   	   bs=bs+b;
	   	   
	   	}
     }
     for(a=99;a>=95;a--)//去后零 
     {   if(a==99-xsd&&bj==0)
	     {
     		bj=1;
     		flag=99-a;
     	 } 
	     if(shu[a]!=0&&bj==0)
         {
      	  bj=1;
     	  flag=99-a;
         }
     }
     for(l=c;l>1;l--)//计算 
     {
      for(a=99;a>0;a--)
      {
	    shu[a]=shu[a]*bs;
      }
      for(a=99;a>1;a--)
      {   
        shu[a-1]=shu[a-1]+shu[a]/10;
    	shu[a]=shu[a]%10;
      }
     }
     for(a=0;a<100-flag*c;a++)//输出
	 {  if(a>=100-xsd*c)
	    {
    		ll=1;
    	}
 		if(shu[a]==0&&ll==0)
		 {
		 }
		 else
		 {
 			if(a==(100-xsd*c))
 			{
			 printf(".");	
		    }
		    printf("%d",shu[a]);
			ll=1;		    
 		 }
 	 }
     printf("\n");   
   }
}

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