C语言程序设计现代方法第16章答案(7)

2021-02-21 12:24

/********************************************************** * search: Prompts the user to enter a part number, then * * looks up the part in the inv array. If the * * part exists, prints the name and quantity on * * hand; if not, prints an error message. * **********************************************************/ void search(const struct part inv[], int np)

{

int i, number;

printf("Enter part number: ");

scanf("%d", &number);

i = find_part(number, inv, np);

if (i >= 0) {

printf("Part name: %s\n", inv[i].name);

printf("Quantity on hand: %d\n", inv[i].on_hand); } else

printf("Part not found.\n");

}

/********************************************************** * update: Prompts the user to enter a part number. * * Prints an error message if the part can't be * * found in the inv array; otherwise, prompts the * * user to enter change in quantity on hand and * * updates the array. * **********************************************************/ void update(struct part inv[], int np)

{

int i, number, change;

printf("Enter part number: ");

scanf("%d", &number);

i = find_part(number, inv, np);

if (i >= 0) {

printf("Enter change in quantity on hand: ");

scanf("%d", &change);

inv[i].on_hand += change;

} else

printf("Part not found.\n");

}

/********************************************************** * print: Prints a listing of all parts in the inv array, *


C语言程序设计现代方法第16章答案(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:毛泽东思想和中国特色社会主义理论体系概论课后习题答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: