Advertisement
Spocoman

05. Challenge the Wedding

Aug 30th, 2024
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ChallengeTheWedding {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int men = Integer.parseInt(scanner.nextLine()),
  7.                 women = Integer.parseInt(scanner.nextLine()),
  8.                 tables = Integer.parseInt(scanner.nextLine());
  9.  
  10.         for (int i = 1; i <= men; i++) {
  11.             for (int k = 1; k <= women; k++) {
  12.                 if (tables == 0) {
  13.                     break;
  14.                 }
  15.                 System.out.printf("(%d <-> %d) ", i, k);
  16.                 tables--;
  17.             }
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement