博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
实验4-7 条件操作符
阅读量:4144 次
发布时间:2019-05-25

本文共 338 字,大约阅读时间需要 1 分钟。

 实验目的:

掌握条件操作符

实验步骤:

1.条件表达式i>j?++i:++j是如何求值的?为什么?编程验证。

 怎样看条件操作符和if-else结构的关系?

2. if(a > b)

max = a;

else

     max = b;

可以改写为(a > b)?(max = a):(max = b),其中的括号可能去掉吗?为什么?

还可以改写为                   

3.用条件操作符改写下面的if-else结构。(用两种方式)

if(a>b)

              printf("%d\n", a);

       else

              printf("%d\n", b);

4.分析表达式a > b ? a : c > d ? c++ : d++。

注意:

分析完如何求值后,还应分析此表达式的可读性。

转载地址:http://kddti.baihongyu.com/

你可能感兴趣的文章
Commit our mod to our own repo server
查看>>
LOCAL_PRELINK_MODULE和prelink-linux-arm.map
查看>>
Simple Guide to use the gdb tool in Android environment
查看>>
Netconsole to capture the log
查看>>
Build GingerBread on 32 bit machine.
查看>>
How to make SD Card world wide writable
查看>>
Detecting Memory Leaks in Kernel
查看>>
Linux initial RAM disk (initrd) overview
查看>>
Timestamping Linux kernel printk output in dmesg for fun and profit
查看>>
There's Much More than Intel/AMD Inside
查看>>
CentOS7 安装MySQL 5.6.43
查看>>
使用Java 导入/导出 Excel ----Jakarta POI
查看>>
本地tomcat 服务器内存不足
查看>>
IntelliJ IDAE 2018.2 汉化
查看>>
基于S5PV210的uboot移植中遇到的若干问题记录(一)DM9000网卡移植
查看>>
Openwrt源码下载与编译
查看>>
我和ip_conntrack不得不说的一些事
查看>>
Linux 查看端口使用情况
查看>>
文件隐藏
查看>>
两个linux内核rootkit--之二:adore-ng
查看>>