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:VS2008编译过的都CE,有没有搞错啊,高手帮忙看一下

Posted by kanqimingtian at 2011-05-18 14:55:31 on Problem 1001
In Reply To:VS2008编译过的都CE,有没有搞错啊,高手帮忙看一下 Posted by:liuweibiao at 2011-04-16 15:17:11
> #include <stdio.h> 
> #include <string.h> 
> #define MAX_LEN 200 
> unsigned an1[MAX_LEN+10]; 
> unsigned an2[MAX_LEN*2+10]; 
> unsigned aResult[MAX_LEN * 2 + 10]; 
> char szLine1[MAX_LEN+10]; 
> void multi(unsigned int *an1,unsigned int *an2,unsigned int *aResult ,int &nLen1,int &nLen2)
> {
>  int i,j;
> for( i = 0;i < nLen2; i ++ )  { //每一轮都用 an1 的一位,去和 an2 各位相乘 
>           //从 an1 的个位开始 
>  for( j = 0; j < nLen1; j ++ )  //用选定的 an1 的那一位,去乘 an2的各位  
>   aResult[i+j] += an2[i]*an1[j]; //两数第i, j 位相乘,累加到结果的第 i+j 位 
> } 
>  //下面的循环统一处理进位问题 
>  for( i = 0; i < MAX_LEN * 2; i ++ ) { 
>  if( aResult[i] >= 10 ) { 
>    aResult[i+1] += aResult[i] / 10; 
>    aResult[i] %= 10; 
>   } 
>  } 
>  nLen2=nLen2+nLen1+1;
>  memcpy(an2,aResult,MAX_LEN*2+10);
>  
>  memset(aResult,0,MAX_LEN*2+10);
> }
> int main() 
> { 
>  int n;
>  while(scanf("%s %d",szLine1,&n)!=EOF)
>  {
>  int i, j,k=-2,m; 
> int nLen1 = strlen( szLine1); 
> memset( an1, 0, sizeof(an1));
> memset(an2,0,sizeof(an2));
> memset( aResult, 0, sizeof(aResult));  
> j = 0; 
> for( i = nLen1 - 1;i >= 0 ; i --) 
> {
> 	if(szLine1[i]=='.')
> 	{
> 		k=strlen(szLine1)-i-1;
> 		continue;
> 	}
>  an1[j++] = szLine1[i] - '0';
>  
> }
> int nLen2 = strlen(szLine1);
> for(j=0;j<nLen1;j++)
> an2[j]=an1[j];
> for(i=0;i<n-1;i++)
> multi(an1,an2,aResult,nLen1,nLen2);
> m=k*n;
> for(i=nLen2;i>=m;i--)
> if(an2[i]!=0)
> {
> 	m=i;
> 	break;
> }
> for(i=0;i<nLen2;i++)
> if(an2[i]!=0)
> {
> 	j=i;
> 	break;
> }
> if(an2[m]==0)
> printf(".");
> else
> printf("%u",an2[m]);
> for(i=m-1;i>=j;i--)
> {
> printf("%u",an2[i]);
> if(i==k*n)
> printf(".");
> 
> }
> printf("\n");
>  }
>  return 0;
> }
> 
> 

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