akskater100

C17-II Q2

May 7th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. public class Q2 {
  2.     public static boolean swing(int p, int q) {
  3.         return (p%q) == (p-(q*p/q));
  4.     }
  5.  
  6.     public static boolean polka(int p, int q) {
  7.         return (p%q) < (p-q);
  8.     }
  9.     public static void testA() {
  10.         for (int i = 1; i <= 10; i++) {
  11.             for (int j = 1; j <= 10; j++) {
  12.                 System.out.println("i: "+i+"\nj: "+j+"\n"+(swing(i,j)==polka(i,j)));
  13.             }
  14.         }
  15.     }
  16.     public static void testC() {
  17.         for (int i = 1; i <= 10; i++) {
  18.             for (int j = 1; j <= 10; j++) {
  19.                 if(i>=j)
  20.                 System.out.println("i: "+i+"\nj: "+j+"\n"+(swing(i,j)==polka(i,j)));
  21.             }
  22.         }
  23.     }
  24.     public static void testD() {
  25.         for (int i = 1; i <= 10; i++) {
  26.             for (int j = 1; j <= 10; j++) {
  27.                 if(i<j)
  28.                 System.out.println("i: "+i+"\nj: "+j+"\n"+(swing(i,j)==polka(i,j)));
  29.             }
  30.         }
  31.     }
  32.     public static void testE() {
  33.         for (int i = 1; i <= 10; i++) {
  34.             for (int j = 1; j <= 10; j++) {
  35.                 if(i%j==0)
  36.                 System.out.println("i: "+i+"\nj: "+j+"\n"+(swing(i,j)==polka(i,j)));
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment