Facebook
From Florian H, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 130
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner sc = new Scanner(System.in);
  8.  
  9.         int state = 0;
  10.         int input = sc.nextInt();
  11.  
  12.         while (input < 2 && input > -1) {
  13.             if (input == 1) {
  14.                 if (state == 0) {
  15.                     state = 1;
  16.                 } else if (state == 1) {
  17.                     state = 0;
  18.                 } else if (state == 2) {
  19.                     state = 3;
  20.                 } else {
  21.                     state = 2;
  22.                 }
  23.             } else {
  24.                 if (state == 0) {
  25.                     state = 3;
  26.                 } else if (state == 1) {
  27.                     state = 2;
  28.                 } else if (state == 2) {
  29.                     state = 1;
  30.                 } else {
  31.                     state = 0;
  32.                 }
  33.             }
  34.  
  35.             input = sc.nextInt();
  36.         }
  37.         if (state == 0) {
  38.             System.out.print("accepted.");
  39.         } else {
  40.             System.out.print("rejected.");
  41.         }
  42.     }
  43.  
  44.  
  45.  
  46. }
  47.