Easy Tutorial
❮ C Function Fgetpos C Exercise Example69 ❯

C Exercise Example 22

C Language Classic 100 Examples

Question: Two ping pong teams compete, each with three players. Team A consists of players a, b, and c, while Team B consists of players x, y, and z. The match list has been determined by drawing lots. Someone inquired about the match list from the players. a said he does not play against x, and c said he does not play against x and z. Please write a program to find the match list for the three pairs.

Example

//  Created by www.tutorialpro.org on 15/11/9.
//  Copyright © 2015年 tutorialpro.org. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char i,j,k;
    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("Order is: a--%c\tb--%c\tc--%c\n",i,j,k);
                        }
                    }
                }
            }
        }
    }
}

The output of the above example is:

Order is: a--z    b--x    c--y

C Language Classic 100 Examples

❮ C Function Fgetpos C Exercise Example69 ❯