C Primer Plus(第6版)第九章复习题答案

题号

1

  • 实际参数和形式参数的区别是什么?

实际参数(actual argument)是指调用函数时传递给形式参数的值,形式参数(formal parameter)是指在函数定义时括号内的值,是本函数私有的局部变量

2

请添加图片描述

a.void donut(int num)
b.int gear(int a,int b)
c.int guess(void)
d.void stuff_it(double a,double *pd)

3

请添加图片描述

char n_to_char(int a)
int digit(double a,int b)
double * which(double *pd1,double *pd2)
int random(void)

4 5

请添加图片描述

int sum(int a,int b){
	return a + b;
}
double sum(double a,double b){
	return a + b;
	}

6 7

请添加图片描述

void alter(int *x,int *y){
	int temp = *x + *y;
	*x = temp;
	*y = *x - 2 *(*y);
}
void salami(int num){
	int count;
	for (count = 1; count <= num; count++)
		printf("  O salami mio ! \n");
}

8

请添加图片描述

int max(int a, int b, int c)
{
    return a > b ? (a > c ? a : c) : (b > c ? b : c);
}

9

请添加图片描述

#include <stdio.h>
#include <stdlib.h>
 
void menu()
{
    printf("Please choose one of the following: \n");
    printf("1) copy files            2) move files \n");
    printf("3) remove files          4) quit\n");
    printf("Enter the number of your choice:");
}
 
int limit(int a, int b)
{
    int num;
    while(scanf("%d", &num) == 1)
    {
        if(num >= a && num <= b)
        {
            return num;
        }
        else
        {
            menu();
        }
    }
    return 4;
}
 
int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    int x = limit(a, b);
    printf("\nXXXX%d\n", x);
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值