> 其他 >
C语言:计算表达式x^y的值,分别输出它们的整数部分和小数部分.
输入有若干行,每行两个数x、y.
当x
人气:252 ℃ 时间:2020-02-06 01:40:36
解答
/*
5 6
15625 + 0
1.2 3
1 + 0.728
-2 3
输入不合要求.
3 1.8
7 + 0.224674
q
Press any key to continue
*/
#include <stdio.h>
#include <math.h>

int main(void) {
\x05double x,y,dx;
\x05int ix;
\x05while(scanf("%lf%lf",&x,&y) == 2) {
\x05\x05if(x < 0) {
\x05\x05\x05printf("输入不合要求.\n");
\x05\x05\x05continue;
\x05\x05}
\x05\x05dx = pow(x,y);
\x05\x05ix = (int)dx;
\x05\x05dx -= ix;
\x05\x05printf("%d + %g\n",ix,dx);
\x05}
\x05return 0; 
}
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版