C Primer Plus 第六版第五章编程练习答案

部分习题代码丢失,需要请联系博主。
编译环境:Visual Studio 2017

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<float.h>
#include<math.h>
void lifang(double x);
void Temperatures(double a);
******************************************************************************
/* practice 1      
void p5_1(void)
{
    const int m2h=60;
    int min;
    printf("Please input minutes:\n");
    scanf("%d", &min);
    while (min>0)
    {
       printf("equal %d hour and %d minutes\n", min/m2h, min%m2h);
       scanf("%d", &min);
    }
    system("pause");
}

/* practice 2      
void p5_2(void)
{
    int a,b;
    printf("Please input a number:\n");
    scanf("%d", &a);
    b = a + 10;
    while (++a<=b)
        printf("%d ", a);
    system("pause");
}

/* practice 7      
void p5_7(void)
{
    double a;
    printf("Please input a double numer:\n");
    scanf("%lf", &a);
    lifang(a);
    system("pause");
}

void lifang(double x)
{
    printf("%lf", pow(x,3));
}

/* practice 8      
void p5_8(void)
{
    int a, b;
    a = 256;
    scanf("%d", &b);
    while (b!=0)
    {
        printf("%d\n", b%a);
        scanf("%d", &b);
    }
    system("pause");
}

/* practice 9      
void p5_9(void)
{
    double a;
    int b;
    b = scanf("%lf", &a);
    while (b==1)
    {
     Temperatures(a);
     b=scanf("%lf", &a);
    }
    system("pause");
}

void Temperatures(double a)
{
    const int b = 273.15;
    printf("%lf\n", a);
    printf("%lf\n", a+b);
}

2015.5.16

猜你喜欢

转载自blog.csdn.net/qq_38967295/article/details/80331605