当前位置:网站首页>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;} 边栏推荐
- 应用层协议——DNS
- 绿盾加密如何顺利切换成IP-Guard加密
- 【FPGA教程案例50】控制案例2——基于FPGA的PD控制器verilog实现
- [Actual combat scene] Mall-discount event design plan
- ERROR: Could not install packages due to an OSError: [Errno 2] 没有那个文件或目录: ‘/data/xxxx
- Embedded Sharing Collection 33
- The shortest path out of the maze
- Research on a Consensus Mechanism-Based Anti-Runaway Scheme for Digital Trunking Terminals
- ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/data/xxxx
- Kong implements ban on foreign IP access
猜你喜欢

剑指offer_抽象建模能力

交换机和路由器技术-28-OSPF的NSSA区域

ALSA音频架构 -- aplay播放流程分析

C语言:实用调试技巧

Switches and routers technology - 21 - RIP routing protocol

交换机和路由器技术-29-OSPF虚链路

【yolov7系列三】实战从0构建训练自己的数据集

破解事务性工作瓶颈,君子签电子合同释放HR“源动力”!

0 Basic software test for career change, self-study for 3 months, 12k*13 salary offer

To break the bottleneck of transactional work, the gentleman signs the electronic contract to release the "source power" of HR!
随机推荐
破解事务性工作瓶颈,君子签电子合同释放HR“源动力”!
Jetson Orin平台4-16路 GMSL2/GSML1相机采集套件推荐
Events and scheduled tasks in Mysql
svg-icon的使用方法(svg-sprite-loader插件)
02.折叠隐藏文字
Summary of c language fprintf, fscanf, sscanf and sprintf function knowledge points
Bubble sort and heap sort
Three 】 【 yolov7 series of actual combat from 0 to build training data sets
Switch and Router Technology - 28 - NSSA Areas for OSPF
梅克尔工作室--OpenEuler培训笔记(1)
About data paging display
Kong implements ban on foreign IP access
form form submission database Chinese becomes a question mark
对象的创建以及显示转换
zabbix构建企业级监控告警平台
在 关闭页面/卸载(unload)文档 之前向服务器发送请求
[Server installation mysql] Use mysql offline installation package to install mysql5.7 under centos7
Redis: Solve the problem of modifying the same key with distributed high concurrency
ERROR: Could not install packages due to an OSError: [Errno 2] 没有那个文件或目录: ‘/data/xxxx
How to add icons to web pages?