"c语言练习题答案:谭浩强C语言习题详细解答,12章全覆盖"
需积分: 0 173 浏览量
更新于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."
点击了解资源详情
点击了解资源详情
点击了解资源详情
2012-10-08 上传
2009-04-03 上传
2024-03-03 上传
2021-10-24 上传
2022-07-11 上传
u010164222
- 粉丝: 0
- 资源: 1
最新资源
- WordPress作为新闻管理面板的实现指南
- NPC_Generator:使用Ruby打造的游戏角色生成器
- MATLAB实现变邻域搜索算法源码解析
- 探索C++并行编程:使用INTEL TBB的项目实践
- 玫枫跟打器:网页版五笔打字工具,提升macOS打字效率
- 萨尔塔·阿萨尔·希塔斯:SATINDER项目解析
- 掌握变邻域搜索算法:MATLAB代码实践
- saaraansh: 简化法律文档,打破语言障碍的智能应用
- 探索牛角交友盲盒系统:PHP开源交友平台的新选择
- 探索Nullfactory-SSRSExtensions: 强化SQL Server报告服务
- Lotide:一套JavaScript实用工具库的深度解析
- 利用Aurelia 2脚手架搭建新项目的快速指南
- 变邻域搜索算法Matlab实现教程
- 实战指南:构建高效ES+Redis+MySQL架构解决方案
- GitHub Pages入门模板快速启动指南
- NeonClock遗产版:包名更迭与应用更新