Advertisement
desislava_topuzakova

03. Characters in Range

Jun 12th, 2022
1,165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.40 KB | None | 0 0
  1. SoftUni Judge
  2. Contests
  3. Submissions
  4. Feedback
  5. Administration
  6. Hello, desislava.topuzakova!
  7. Log out
  8. Search
  9. Home Submissions 23088909
  10. Solution #23088909 by desislava.topuzakova for problem 03. Characters in Range
  11.  
  12. Zero test #1 (Correct answer) Run #223822102 Test #102026
  13. The zero tests are not included in the final result.
  14. Expected output:Your output:
  15. 1
  16. b c
  17. 1
  18. b c
  19. Time used: 0.045 s
  20. Memory used: 0.00 MB
  21. Zero test #2 (Correct answer) Run #223822103 Test #102027
  22. The zero tests are not included in the final result.
  23. Expected output:Your output:
  24. 1
  25. $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9
  26. 1
  27. $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9
  28. Time used: 0.070 s
  29. Memory used: 0.00 MB
  30. Zero test #3 (Correct answer) Run #223822104 Test #102028
  31. The zero tests are not included in the final result.
  32. Expected output:Your output:
  33. 1
  34. $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B
  35. 1
  36. $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B
  37. Time used: 0.073 s
  38. Memory used: 0.00 MB
  39. Test #1 (Correct answer) Run #223822105 Test #102029
  40. Expected output:Your output:
  41. 1
  42. c d e f g h i j k l m n o p q
  43. 1
  44. c d e f g h i j k l m n o p q
  45. Time used: 0.056 s
  46. Memory used: 0.00 MB
  47. Test #2 (Correct answer) Run #223822106 Test #102030
  48. Expected output:Your output:
  49. 1
  50. 2 3 4 5 6 7 8
  51. 1
  52. 2 3 4 5 6 7 8
  53. Time used: 0.069 s
  54. Memory used: 0.00 MB
  55. Test #3 (Correct answer) Run #223822107 Test #102031
  56. Expected output:Your output:
  57. 1
  58. " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
  59. 1
  60. " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
  61. Time used: 0.073 s
  62. Memory used: 0.00 MB
  63. Test #4 (Correct answer) Run #223822108 Test #102032
  64. Expected output:Your output:
  65. 1
  66. B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y
  67. 1
  68. B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y
  69. Time used: 0.052 s
  70. Memory used: 0.00 MB
  71. Source code
  72. 1
  73. package Methods_Exercise;
  74. 2
  75. 3
  76. import java.util.Scanner;
  77. 4
  78. 5
  79. public class CharactersInRange_03 {
  80. 6
  81.    public static void main(String[] args) {
  82. 7
  83.        Scanner scanner = new Scanner(System.in);
  84. 8
  85.        char symbol1 = scanner.nextLine().charAt(0);
  86. 9
  87.        char symbol2 = scanner.nextLine().charAt(0);
  88. 10
  89.        //метод, който отпечатва ред с всички символи от по-малкия (< аски код)
  90. 11
  91.        printSequenceOfChars(symbol1, symbol2);
  92. 12
  93.    }
  94. 13
  95. 14
  96.    private static void printSequenceOfChars(char symbol1, char symbol2) {
  97. 15
  98.        //проверка от кой символ да започнем
  99. 16
  100.        if (symbol1 < symbol2) {
  101. 17
  102.            //започваме от symbol1 до symbol2
  103. 18
  104.            //a до d -> b c
  105. 19
  106.            for (char symbol = (char)(symbol1 + 1); symbol < symbol2; symbol++) {
  107. 20
  108.                System.out.print(symbol + " ");
  109. 21
  110.            }
  111. 22
  112.        } else { //symbol1 >= symbol2
  113. 23
  114.            //започваме от symbol2
  115. 24
  116.            for (char symbol = (char)(symbol2 + 1); symbol < symbol1; symbol++) {
  117. 25
  118.                System.out.print(symbol + " ");
  119. 26
  120.            }
  121. 27
  122.        }
  123. 28
  124. 29
  125.    }
  126. 30
  127. }
  128. 31
  129. Created on: 08/10/2021 19:39:36
  130.  
  131. Modified on: 22/12/2021 14:19:59
  132.  
  133. © 2011-2022 - Open Judge System (OJS) 1.5.20150729.95737d0 - running on Windows. Open source project.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement