"c语言练习题答案:谭浩强C语言习题详细解答,12章全覆盖"
需积分: 0 107 浏览量
更新于2024-03-13
收藏 574KB DOC 举报
&x,&y,&z);max=(a>b)?a:b;max=(max>c)?max:c;printf("最大者是%d\n",max);}这个程序实现的功能是输入三个数a、b、c,然后找出其中最大的数并输出。程序首先定义了四个整型变量a、b、c、max,然后通过printf函数提示用户输入三个数,接着通过scanf函数分别将用户输入的三个数赋值给a、b、c。接着利用三目运算符(条件?为真时的值:为假时的值)来进行比较,如果a>b,则max=a,否则max=b;然后再利用三目运算符来比较max和c,找出其中最大的数赋值给max,最后通过printf函数输出max的值,即为最大者。"
"The C language exercise answers; Tan Haoqiang's C language exercises and answers, a total of 12 chapters. Very detailed, please check.; 1.6 Write a program, input three values a, b, c, and output the largest value. Solution: main () {int a, b, c, max; printf ("Please enter three numbers a, b, c: \n"); scanf ("%d,%d,%d", &x, &y, &z); max = (a> b)? a: b; max = (max> c)? max: c; printf ("The largest one is %d\n", max);} This program is to input three numbers a, b, c, and then find the largest number and output it. The program first defines four integer variables a, b, c, max, then prompts the user to enter three numbers through the printf function, and then assigns the three numbers entered by the user to a, b, and c through the scanf function. Then use the ternary operator (condition? Value when true: Value when false) to compare, if a> b, then max = a, otherwise max = b; and then use the ternary operator to compare max and c, find the largest number and assign it to max, and finally use the printf function to output the value of max, which is the largest one."
2023-08-09 上传
2024-06-13 上传
2023-11-18 上传
2024-01-01 上传
2023-05-26 上传
2024-01-30 上传
2024-04-29 上传
u010164222
- 粉丝: 0
- 资源: 1
最新资源
- 新型智能电加热器:触摸感应与自动温控技术
- 社区物流信息管理系统的毕业设计实现
- VB门诊管理系统设计与实现(附论文与源代码)
- 剪叉式高空作业平台稳定性研究与创新设计
- DAMA CDGA考试必备:真题模拟及章节重点解析
- TaskExplorer:全新升级的系统监控与任务管理工具
- 新型碎纸机进纸间隙调整技术解析
- 有腿移动机器人动作教学与技术存储介质的研究
- 基于遗传算法优化的RBF神经网络分析工具
- Visual Basic入门教程完整版PDF下载
- 海洋岸滩保洁与垃圾清运服务招标文件公示
- 触摸屏测量仪器与粘度测定方法
- PSO多目标优化问题求解代码详解
- 有机硅组合物及差异剥离纸或膜技术分析
- Win10快速关机技巧:去除关机阻止功能
- 创新打印机设计:速释打印头与压纸辊安装拆卸便捷性