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


边栏推荐
猜你喜欢

量化框架backtrader之一文读懂observer观测器

How to convert data in cell cell into data in matrix

Comparison of disk partition modes (MBR and GPT)

登录认证服务

Matlab programming related knowledge

Electron

GDAL multiband synthesis tool

One article of the quantification framework backtrader read observer

Sword finger offer 15.65.56 I 56Ⅱ. Bit operation (simple - medium)

Electron
随机推荐
Sword finger offer 18.22.25.52 Double pointer (simple)
Eigen(3):error: ‘Eigen’ has not been declared
Electron
Question bank and answers of the latest Guizhou construction eight (Mechanics) simulated examination in 2022
扩展-Hooks
1075 pat judge (25 points)
【async/await】--异步编程最终解决方案
Sword finger offer 06.24.35 Linked list
What is the ranking of Guosen Securities? Is it safe to open a stock account?
Server create virtual environment run code
SwiftUI找回丢失的列表视图(List)动画
ArcGIS batch render layer script
Where do people get their top energy?
fileinput.js php,fileinput
Codeforces Global Round 21A~D
VMware partial settings
Two dimensional DFS
oracle11g数据库导入导出方法教程[通俗易懂]
MySQL主从复制与读写分离
STM32F1和GD32F1有什么区别?