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

怎么输入n组数据并判定输入结束(C)?

Posted by geniusxsy at 2003-12-13 19:35:45 on Problem 1001
???
如果单是求一个浮点数的N次方,我的程序绝对问题(fun部分)。UNIX上调试过了,无误。

void fun(float a,int n)
{ long al,temp1,temp2;
 short b[150]={0};
 int i,j,k=0;
 short *p;p=b;
    while(a!=(float)((int)a))
 {a*=10;k++;
 }
 k=k*n;
 al=(int)a;
 b[149]=1;
 for(i=0;i<n;i++)
 { temp2=0;
    for(j=149;j>=0;j--)
      { temp1=b[j]*al+temp2;
        b[j]=temp1%10;
        temp2=temp1/10;
       }
  }
  while(*p==0&&p<149-k) p++;
  for(;p<b+150-k;p++)
  printf("%d",*p);
  printf(".");
  for(;p<b+150;p++)
  printf("%d",*p);
}

main()
{????

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