Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. package javaapplication112;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.Locale;
  7.  
  8. public class JavaApplication112 {
  9.  
  10. public static void main(String[] args) throws IOException, Exception {
  11. BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  12.  
  13. // Zadanie 1
  14. /*
  15. String inputLine = in.readLine();
  16.  
  17. String []ds = inputLine.trim().split("[ \t]+");
  18. double r1 = Double.parseDouble(ds[0]);
  19. double r2 = Double.parseDouble(ds[ds.length - 1]);
  20.  
  21. System.out.printf(Locale.US, "r1=%g r2=%g\n", r1, r2);
  22. System.out.printf(Locale.US, "r1+r2=%g\n", r1 + r2);
  23. */
  24.  
  25. // Zadanie 2
  26. /*
  27. String inputLine = in.readLine();
  28.  
  29. String []ds = inputLine.trim().split("[ \t]+");
  30. double sum = 0.0;
  31.  
  32. for (String str : ds) {
  33. if (str.isEmpty()) continue;
  34. sum += Double.parseDouble(str);
  35. }
  36.  
  37. System.out.printf(Locale.US, "sum=%g\n", sum);
  38. */
  39.  
  40. // Zadanie 3
  41. /*
  42. String imieRegex = ".*(?i)bartek.*";
  43. String imie2Regex = ".*(?i)bart[l≥]omiej.*";
  44.  
  45. String inputLine = in.readLine();
  46.  
  47. if (inputLine.matches(imieRegex) || inputLine.matches(imie2Regex)) {
  48. System.out.println(inputLine);
  49. }
  50. */
  51.  
  52. // Zadanie 4
  53. /*
  54. String regex = "[ \t,-.?!\\(\\);\"\':\\[\\]]+";
  55. int slowa = in.readLine().trim().split(regex).length;
  56. System.out.println(slowa);
  57. */
  58.  
  59. // Zadanie 5
  60. /*
  61. String inputLine = in.readLine().trim();
  62. String regex = "([0-2]?[0-9]|3[0-1])\\.(0?[0-9]|1[0-2])\\.[0-9]+";
  63.  
  64. if (inputLine.matches(regex)) {
  65. System.out.println("Poprawna data");
  66. }
  67.  
  68. assert !"12,12,12".matches(regex);
  69. assert !"2.10.".matches(regex);
  70. assert !"120.120.123".matches(regex);
  71. assert !"nic".matches(regex);
  72. assert !"127.0.0.1".matches(regex);
  73. assert !"32.9.2019".matches(regex);
  74. assert !"30.13.2019".matches(regex);
  75. assert "1.12.2019".matches(regex);
  76. assert "1.1.2019".matches(regex);
  77. assert "01.1.2019".matches(regex);
  78. assert "01.01.2019".matches(regex);
  79. */
  80.  
  81. // Zadanie 6
  82. /*
  83. System.out.print("Podaj s≥owo: ");
  84. String slowo = in.readLine();
  85.  
  86. if (slowo.matches(".*[ \t]+.*")) {
  87. throw new Exception("Z≥e s≥owo");
  88. }
  89.  
  90. String regex = ".*(?i)" + slowo + ".*";
  91. String linia = in.readLine();
  92.  
  93. if (linia.matches(regex)) {
  94. System.out.println(linia);
  95. }
  96.  
  97. if (linia.contains(slowo)) {
  98. System.out.println(linia);
  99. }
  100. */
  101.  
  102. // Zadanie 7
  103.  
  104. /*
  105. int lessThan20 = 0;
  106. int counter = 0;
  107.  
  108. while (lessThan20 < 10 && counter < 100) {
  109. long randomNum = Math.round(Math.random() * 100);
  110.  
  111. if (randomNum < 20) {
  112. System.out.println(randomNum);
  113. lessThan20++;
  114. }
  115.  
  116. counter++;
  117. }
  118. */
  119.  
  120. // Zadanie 8
  121. int [][]tablica = {
  122. { 10 },
  123. { 12, 14 },
  124. { 16, 18, 20 },
  125. { 22, 24, 26, 28 },
  126. { 30, 32, 34, 36, 38 },
  127. };
  128.  
  129. for (int i = 0; i < tablica.length; i++) {
  130. for (int j = 0; j < tablica[i].length; j++) {
  131. System.out.print(tablica[i][j] + " ");
  132. }
  133.  
  134. System.out.println();
  135. }
  136.  
  137. // Zadanie 9
  138. }
  139.  
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement