当前位置:网站首页>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;}
边栏推荐
- [Note] Is the value of BatchSize the bigger the better?
- 交换机和路由器技术-30-标准ACL
- 0 Basic software test for career change, self-study for 3 months, 12k*13 salary offer
- 一起Talk编程语言吧
- jwsManager服务接口实现类-jni实现
- 优化是一种习惯●出发点是“站在靠近临界“的地方
- 论文笔记:Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks
- ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/data/xxxx
- 交换机和路由器技术-24-OSPF单区域配置
- 【FPGA教程案例49】控制案例1——基于FPGA的PID控制器verilog实现
猜你喜欢
随机推荐
Summary of c language fprintf, fscanf, sscanf and sprintf function knowledge points
延长经济保险(jeecgboot)
Switch and Router Technology-29-OSPF Virtual Link
Use Navicat Premium to export database table structure information to Excel
增加PRODUCT_BOOT_JARS及类 提供jar包给应用
Mysql: set the primary key to automatically increase the starting value
map and set - natural search and lookup semantics
How to switch Green Shield encryption to IP-Guard encryption smoothly
标识密码技术在 IMS 网络中的应用
论文笔记:Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks
交换机和路由器技术-33-静态NAT
[Actual combat scene] Mall-discount event design plan
Switches and routers technology - 21 - RIP routing protocol
视觉任务种常用的类别文件之一json文件
我的LaTeX入门
交换机和路由器技术-25-OSPF多区域配置
2.2 user manual] [QNX Hypervisor 10.15 vdev timer8254
应用层协议——DNS
JwsManager service interface implementation class - the jni implementation
The sword refers to offer_abstract modeling capabilities