当前位置:网站首页>C语言刷题随记 —— 乒乓球比赛
C语言刷题随记 —— 乒乓球比赛
2022-06-26 13:56:00 【繁依Fanyi】
题目
两个乒乓球队进行比赛,各出三人。甲队为 a,b,c 三人,乙队为 x,y,z 三人,通过抽签决定比赛名单。
有人向队员打听比赛的名单。a 说他不和 x 比,c 说他不和 x,z 比,请编程序找出三队赛手的名单。
思路
利用循环遍历,并利用条件语句逐一排除即可。
题解
#include <stdio.h>
int main()
{
char i,j,k; // i 是 a 的对手,j 是 b 的对手,k 是 c 的对手
for(i='x';i<='z';i++)
{
for(j='x';j<='z';j++)
{
if(i!=j)
for(k='x';k<='z';k++)
{
if(i!=k&&j!=k)
{
if(i!='x'&&k!='x'&&k!='z')
{
printf("名单为:a--%c\tb--%c\tc--%c\n",i,j,k);
}
}
}
}
}
}
样例输出
边栏推荐
- Sectigo的IP证书申请流程
- Electron
- idea快捷键
- transformers DataCollatorWithPadding类
- How to convert data in cell cell into data in matrix
- Freefilesync folder comparison and synchronization software
- Complete diagram / Euler loop
- Correlation of XOR / and
- MHA high availability coordination and failover
- GDAL and opencv smooth and blur TIF images
猜你喜欢
Complimentary Book Cognitive Control: how does our brain accomplish tasks?
从Celsius到三箭:加密百亿巨头们的多米诺,史诗级流动性的枯竭
Never use redis expired monitoring to implement scheduled tasks!
人的顶级能量从哪里获取?
C language | Consortium
Usage of unique function
备战数学建模31-数据插值与曲线拟合3
Sword finger offer 15.65.56 I 56Ⅱ. Bit operation (simple - medium)
Correlation analysis related knowledge
Setup instance of layout manager login interface
随机推荐
数学建模经验分享:国赛美赛对比/选题参考/常用技巧
大学生值得珍藏的实用网站推荐
What is the ranking of Guosen Securities? Is it safe to open a stock account?
Comparison of disk partition modes (MBR and GPT)
布局管理器~登录界面的搭建实例
Stream常用操作以及原理探索
ArcGIS secondary development - arcpy delete layer
常用控件及自定义控件
工作上对金额价格类小数点的总结以及坑
Naacl2022: (code practice) good visual guidance promotes better feature extraction, multimodal named entity recognition (with source code download)
This is the graceful file system mounting method, which is effective through personal testing
登录认证服务
备战数学建模32-相关性分析2
ArcGIS batch render layer script
通俗语言说BM3D
券商经理给的开户链接安全吗?找谁可以开户啊?
Two point answer, 01 score planning (mean / median conversion), DP
扩展-Hooks
ArcGIS batch export layer script
Mathematical modeling of war preparation 30 regression analysis 2