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


边栏推荐
- ThreadLocal giant pit! Memory leaks are just Pediatrics
- VMware partial settings
- 【async/await】--异步编程最终解决方案
- Caelus - full scene offline mixed Department solution
- 《三体》摘录
- ArcGIS secondary development -- arcpy batch automatic map publishing service
- Related knowledge of libsvm support vector machine
- C语言基础知识入门(大全)「建议收藏」
- Difference between classification and regression
- 从Celsius到三箭:加密百亿巨头们的多米诺,史诗级流动性的枯竭
猜你喜欢

9 articles, 6 interdits! Le Ministère de l'éducation et le Ministère de la gestion des urgences publient et publient conjointement neuf règlements sur la gestion de la sécurité incendie dans les établ

How to personalize VIM editor format (DIY)

Setup instance of layout manager login interface

MySQL master-slave replication and read-write separation

One article of the quantification framework backtrader read observer

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

Codeforces Global Round 21A~D

Knowledge about the determination coefficient R2 and the relationship with the correlation coefficient

Where do people get their top energy?

量化框架backtrader之一文读懂observer观测器
随机推荐
9 articles, 6 interdits! Le Ministère de l'éducation et le Ministère de la gestion des urgences publient et publient conjointement neuf règlements sur la gestion de la sécurité incendie dans les établ
How to personalize VIM editor format (DIY)
Complimentary Book Cognitive Control: how does our brain accomplish tasks?
Error when redis is started: could not create server TCP listening socket *: 6379: bind: address already in use - solution
Atcoder bit operation & Conclusion + formula derivation
ArcGIS secondary development - arcpy delete layer
Sword finger offer 06.24.35 Linked list
ArcGIS batch render layer script
What is the ranking of Guosen Securities? Is it safe to open a stock account?
Deploy the flask environment using the pagoda panel
Build your own PE manually from winpe of ADK
Matlab programming related knowledge
When drawing with origin, capital letter C will appear in the upper left corner of the chart. The removal method is as follows:
C语言基础知识入门(大全)「建议收藏」
GDAL multiband synthesis tool
Oracle ASMM和AMM
Transformers datacollatorwithpadding class
MHA high availability coordination and failover
datasets Dataset类(2)
扩展-Hooks