#4366: 和答案相差20...不知道哪邊有錯...


andy78131 (姿勢就是力量)

學校 : 正修科技大學
編號 : 13317
來源 : [120.118.139.150]
最後登入時間 :
2011-04-13 16:29:36

#include <stdio.h>
#include <stdlib.h>

int main()
{
  long long int a=0,b=0,c=0;

while(scanf("%lld%lld",&a,&b)!=EOF)

 
  c=pow(a,b);
  if(a!=0,b!=0)
  printf("%lld\n",c);
  if(a==0&&b==0)
  printf("All Over.\n");
}
   return 0;
}
#4723: Re:和答案相差20...不知道哪邊有錯...


hchs9910734 (雨昕)

學校 : 國立新竹高級中學
編號 : 15036
來源 : [180.177.1.171]
最後登入時間 :
2021-10-01 00:17:56

#include
#include

int main()
{
  long long int a=0,b=0,c=0;

while(scanf("%lld%lld",&a,&b)!=EOF)

 
  c=pow(a,b);
  if(a!=0,b!=0)
  printf("%lld\n",c);
  if(a==0&&b==0)
  printf("All Over.\n");
}
   return 0;
}

 

+1

#include <stdio.h> 

#include <stdlib.h> 

#include<math.h>

int main(void) 

{

    double a,b,p;

    p=0;

    while((scanf("%lf %lf",&a,&b))!=EOF){

                                   if(a==0 && b==0){printf("All Over.\n");

                                   return 0;}

                                   p=pow(a,b);

                                   printf("%.0lf\n",p);

                                   }

}

不懂錯在哪

煩請高手指點 

#4729: Re:和答案相差20...不知道哪邊有錯...


linishan (L)

學校 : 國立交通大學
編號 : 1090
來源 : [104.132.150.102]
最後登入時間 :
2019-05-10 19:57:54

由於pow回傳型態為double

所以會有小數點誤差 導致回傳值不精確