Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P05_ChallengeTheWedding {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int mensCount = Integer.parseInt(scanner.nextLine());
- int womensCount = Integer.parseInt(scanner.nextLine());
- int maxTableCount = Integer.parseInt(scanner.nextLine());//3
- int tableSeats = maxTableCount * 2;//6
- int counter = 0;
- boolean isFinish = false;
- boolean isSeatsGone = false;
- while (!(tableSeats == counter)){
- for (int i = 1; i <= mensCount; i++) {
- for (int j = 1; j <= womensCount; j++) {
- System.out.printf("(%d <-> %d) ", i , j);
- counter+=2;
- if (i == mensCount && j == womensCount){
- isFinish = true;
- break;
- }
- if (counter == tableSeats){
- break;
- }
- }
- }
- if (isFinish){
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement