当前位置:网站首页>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);
}
}
}
}
}
}
样例输出


边栏推荐
- Oracle ASMM and AMM
- BP neural network for prediction
- JVM 输出 GC 日志导致 JVM 卡住,我 TM 人傻了
- 一个快速切换一个底层实现的思路分享
- Setup instance of layout manager login interface
- A标签去掉下划线
- ArcGIS batch render layer script
- Question bank and answers of the latest Guizhou construction eight (Mechanics) simulated examination in 2022
- Excerpt from three body
- GDAL and opencv smooth and blur TIF images
猜你喜欢

The annual salary of 500000 is one line, and the annual salary of 1million is another line

使用宝塔面板部署flask环境

Where do people get their top energy?

Caelus - full scene offline mixed Department solution

JVM 输出 GC 日志导致 JVM 卡住,我 TM 人傻了

Hard (magnetic) disk (I)

ArcGIS cannot be opened and displays' because afcore cannot be found ' DLL, solution to 'unable to execute code'

备战数学建模31-数据插值与曲线拟合3

2022年最新贵州建筑八大员(机械员)模拟考试题库及答案

Eigen(3):error: ‘Eigen’ has not been declared
随机推荐
Gartner 2022 Top Strategic Technology Trends Report
Lucky numbers in the matrix
Error when redis is started: could not create server TCP listening socket *: 6379: bind: address already in use - solution
'coach, I want to play basketball!'—— AI Learning Series booklet for system students
Sectigo的IP证书申请流程
Atcoder 238
BM3D in popular language
Sword finger offer 21.57.58 I Double pointer (simple)
Extended hooks
启动Redis报错:Could not create Server TCP listening socket *:6379: bind: Address already in use–解决办法
Hard (magnetic) disk (I)
Excerpt from three body
oracle11g数据库导入导出方法教程[通俗易懂]
Where do people get their top energy?
Common controls and custom controls
券商经理给的开户链接安全吗?找谁可以开户啊?
Sword finger offer 06.24.35 Linked list
NAACL2022:(代码实践)好的视觉引导促进更好的特征提取,多模态命名实体识别(附源代码下载)...
Naacl2022: (code practice) good visual guidance promotes better feature extraction, multimodal named entity recognition (with source code download)
C language | Consortium