当前位置:网站首页>C language antithesis: who is the murderer!
C language antithesis: who is the murderer!
2022-08-11 04:55:00 【so-and-so Xiaolu】
The complete code is at the end!
Title description
A murder case occurred somewhere in Japan, and the police determined that the murderer must be one of four suspects through investigation.
The following are the confessions of the four suspects:
A said: Not me.
B said: yes C.
C said: yes D.
D said: C is talking nonsense
3 people are known to tell the truth and 1 person to tell the truth.
Now, based on this information, write a program to determine who the killer is.
Solution ideas
In this question, only one person told a lie and 3 people told the truth. We can return 1 for each time the truth is judged. Three times the truth is three 1s equal to 3. We can use each time to assume that a certain person is the murdererto judge whether what everyone said is the truth.So use the for statement to go from the murderer a to the murderer d, and each judgment is ok
Complete code
#includeint main(){char m;for (char i = 'a'; i <= 'd'; i++){if ((i != 'a') + (i == 'c') + (i == 'd') + (i != 'd') == 3){printf("%c", i);}}return 0;}
边栏推荐
- 对象的创建以及显示转换
- 3 模块二:科研工具使用
- Selenium自动化测试框架工作原理你明白了吗?
- Application layer protocol - DNS
- 二叉堆的基础~
- 论文笔记:Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks
- Solve the problem of multi-thread calling sql stored procedure
- Switch and Router Technology - 28 - NSSA Areas for OSPF
- JVM 垃圾回收的概述与机制
- 2021 Network Planning Designer Afternoon Case Questions
猜你喜欢
ALSA音频架构 -- snd_pcm_open函数分析
梅克尔工作室--OpenEuler培训笔记(1)
网络技能树
【yolov7系列三】实战从0构建训练自己的数据集
Switches and routers technologies - 30 - standard acls
0 Basic software test for career change, self-study for 3 months, 12k*13 salary offer
交换机--- 生成树--三层架构总结
Switches and routers technology - 24 - configure OSPF single area
C语言:实用调试技巧
「转」“搜索”的原理,架构,实现,实践,面试不用再怕了
随机推荐
Switches and routers technology - 24 - configure OSPF single area
Layered Architecture & SOA Architecture
4 模块三:文献阅读与研究方法
C语言:实用调试技巧
Snap - rotate the smallest number of an array
开发工具篇第七讲:阿里云日志查询与分析
二叉堆的基础~
无线电射频能量的收集
FPGA工程师面试试题集锦121~130
Selenium自动化测试框架工作原理你明白了吗?
Jetson Orin平台4-16路 GMSL2/GSML1相机采集套件推荐
leetcode 9. 回文数
【小记】BatchSize的数值是设置的越大越好吗
网络安全培训机构哪家好?排名怎么选择?
交换机和路由器技术-28-OSPF的NSSA区域
延长经济保险(jeecgboot)
【FPGA教程案例49】控制案例1——基于FPGA的PID控制器verilog实现
如何将360全景图导出高清短视频分享到视频平台上?
How to switch Green Shield encryption to IP-Guard encryption smoothly
Merkel Studio--OpenEuler Training Notes (1)