fork download
  1. import java.util.*;
  2.  
  3. public class Main {
  4.  
  5.  
  6. public static void main(String[] args) throws ArrayIndexOutOfBoundsException {
  7.  
  8.  
  9. int[][] tenElementsArray = new int[10000][11];
  10.  
  11. boolean statement = false;
  12. int columnIterator = 0, rowIterator = 0;
  13.  
  14. Scanner sc = new Scanner(System.in);
  15. String userInput;
  16.  
  17.  
  18. while (true) {
  19.  
  20. userInput = sc.next();
  21.  
  22.  
  23.  
  24. if (rowIterator ==0) {
  25. if (userInput.equals("-")) {
  26.  
  27. if (columnIterator > 0) {
  28. rowIterator = 9;
  29. columnIterator--;
  30. System.out.println(":(");
  31. } else {
  32. System.out.println(tenElementsArray[columnIterator][rowIterator ]);
  33. System.out.println(":(");
  34. return;
  35. }
  36. }
  37. if (userInput.equals("+")) {
  38. tenElementsArray[columnIterator][rowIterator] = (sc.nextInt());
  39. System.out.println(":)");
  40. rowIterator++;
  41.  
  42. }
  43. } else {
  44. if (userInput.equals("-")) {
  45. rowIterator--;
  46. System.out.println(tenElementsArray[columnIterator][rowIterator+1]);
  47.  
  48.  
  49. } else if (userInput.equals("+")) {
  50.  
  51.  
  52. if (rowIterator == 10){
  53. tenElementsArray[columnIterator][rowIterator] = (sc.nextInt());
  54.  
  55. rowIterator = 0;
  56. columnIterator++;}
  57. else {
  58. tenElementsArray[columnIterator][rowIterator] = (sc.nextInt());
  59. System.out.println(":)");
  60.  
  61. rowIterator++;
  62.  
  63.  
  64. }}
  65.  
  66. }
  67. }
  68.  
  69.  
  70. }
  71. }
Success #stdin #stdout 0.12s 29960KB
stdin
-
-
-
stdout
0
:(