小编mik*_*key的帖子

scanf()导致奇怪的结果

我有一段代码提出了一个有趣的问题(在我看来).

/*power.c raises numbers to integer powers*/
#include <stdio.h>

double power(double n, int p);

int main(void)
{
    double x, xpow; /*x is the orginal number and xpow is the result*/
    int exp;/*exp is the exponent that x is being raised to */

    printf("Enter a number and the positive integer power to which\n the first number will be raised.\n enter q to quit\n");

    while(scanf("%lf %d", &x, &exp) ==2)
    {
        xpow = power(x, exp);
        printf("%.3g to the power %d is %.5g\n", x, …
Run Code Online (Sandbox Code Playgroud)

c c++ scanf

1
推荐指数
2
解决办法
939
查看次数

标签 统计

c ×1

c++ ×1

scanf ×1