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


边栏推荐
- Gartner 2022 Top Strategic Technology Trends Report
- MHA高可用配合及故障切换
- C | analysis of malloc implementation
- Summary of decimal point of amount and price at work and pit
- Experience sharing of mathematical modeling: comparison between China and USA / reference for topic selection / common skills
- A remove the underline from the label
- DOS command
- SwiftUI找回丢失的列表视图(List)动画
- Leaflet loading ArcGIS for server map layers
- 在线牛人博主
猜你喜欢

From Celsius to the three arrows: encrypting the domino of the ten billion giants, and drying up the epic liquidity

布局管理器~登录界面的搭建实例

Eigen(3):error: ‘Eigen’ has not been declared

聊聊 RPA 方向的规划:简单有价值的事情长期坚持做

Mathematical modeling of war preparation 30 regression analysis 2

New specification of risc-v chip architecture

Jianzhi offer 43.47.46.48 dynamic planning (medium)

Sword finger offer 10 Ⅰ 10Ⅱ. 63 dynamic planning (simple)

Sword finger offer 09.30 Stack

Pycharm远程连接服务器来跑代码
随机推荐
Never use redis expired monitoring to implement scheduled tasks!
1075 pat judge (25 points)
Chinese output of PostGIS console is garbled
Oracle11g database import and export method tutorial [easy to understand]
Oracle ASMM和AMM
布局管理器~登录界面的搭建实例
Codeforces Global Round 21A~D
Heap optimization dijkstra/hash table storage node number
Related knowledge of libsvm support vector machine
'coach, I want to play basketball!'—— AI Learning Series booklet for system students
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
Knowledge about adsorption
fileinput. js php,fileinput
Correlation analysis related knowledge
【async/await】--异步编程最终解决方案
Sword finger offer 45.61 Sort (simple)
The annual salary of 500000 is one line, and the annual salary of 1million is another line
When drawing with origin, capital letter C will appear in the upper left corner of the chart. The removal method is as follows:
Sharing ideas for a quick switch to an underlying implementation
Excerpt from three body