fork(12) download
  1. import java.util.Scanner;
  2. import java.io.Console;
  3. public class Main {
  4.  
  5. /**
  6. int x=0,y=0,zm=0;
  7.  
  8.   do
  9.   {
  10.   scanf("%d",&x);
  11.  
  12.   if (zm==3) return 0;
  13.   else
  14.   {
  15.   if ((x == 42) && (y != x) && (y != 0))
  16.   {
  17.   zm++;
  18.   y=x;
  19.   }
  20.   else y=x;
  21.   }
  22.   printf("%d\n",x);
  23.   }
  24.   while(7);
  25. */
  26. public static void main(String[] args) {
  27. Scanner input = new Scanner(System.in);
  28.  
  29. int x=0,y=0,zm=0;
  30. do{
  31. x = input.nextInt();
  32. if (zm == 3) System.exit(0);
  33. else{
  34. if ((x == 42) && (y != x) && (y != 0))
  35. {
  36. zm++;
  37. y=x;
  38. }
  39. else y=x;
  40. }
  41. System.out.println(x);
  42. }
  43. while(0 == 0);
  44. }
  45.  
  46. }
  47.  
Success #stdin #stdout 0.07s 213888KB
stdin
42
42
12
13
42
11
42
43
42
42
99
01
stdout
42
42
12
13
42
11
42
43
42