#5731: 如何消去小數點?


bowwow5252 (阿望)

學校 : 不指定學校
編號 : 19726
來源 : [182.235.193.8]
最後登入時間 :
2014-03-09 22:24:07

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
double pow(double, double);
int main()
{
    float x;
    printf("please input number : ");
    while(scanf("%f",&x)==1)
    {
    printf("%f\n",pow(2,x));
    }
    return 0;
}

//如何消去小數點呢?但是pow又必需配合用%f

 

#5732: Re:如何消去小數點?


leopan0922 (zz)

學校 : 臺北市立成功高級中學
編號 : 6612
來源 : [140.113.225.106]
最後登入時間 :
2016-08-15 15:44:07

#include
#include
#include
double pow(double, double);
int main()
{
    float x;
    printf("please input number : ");
    while(scanf("%f",&x)==1)
    {
    printf("%.f\n",pow(2,x));
    }
    return 0;
}

//如何消去小數點呢?但是pow又必需配合用%f

 

這樣就可以了