Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication112;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.Locale;
- public class JavaApplication112 {
- public static void main(String[] args) throws IOException, Exception {
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- // Zadanie 1
- /*
- String inputLine = in.readLine();
- String []ds = inputLine.trim().split("[ \t]+");
- double r1 = Double.parseDouble(ds[0]);
- double r2 = Double.parseDouble(ds[ds.length - 1]);
- System.out.printf(Locale.US, "r1=%g r2=%g\n", r1, r2);
- System.out.printf(Locale.US, "r1+r2=%g\n", r1 + r2);
- */
- // Zadanie 2
- /*
- String inputLine = in.readLine();
- String []ds = inputLine.trim().split("[ \t]+");
- double sum = 0.0;
- for (String str : ds) {
- if (str.isEmpty()) continue;
- sum += Double.parseDouble(str);
- }
- System.out.printf(Locale.US, "sum=%g\n", sum);
- */
- // Zadanie 3
- /*
- String imieRegex = ".*(?i)bartek.*";
- String imie2Regex = ".*(?i)bart[l≥]omiej.*";
- String inputLine = in.readLine();
- if (inputLine.matches(imieRegex) || inputLine.matches(imie2Regex)) {
- System.out.println(inputLine);
- }
- */
- // Zadanie 4
- /*
- String regex = "[ \t,-.?!\\(\\);\"\':\\[\\]]+";
- int slowa = in.readLine().trim().split(regex).length;
- System.out.println(slowa);
- */
- // Zadanie 5
- /*
- String inputLine = in.readLine().trim();
- String regex = "([0-2]?[0-9]|3[0-1])\\.(0?[0-9]|1[0-2])\\.[0-9]+";
- if (inputLine.matches(regex)) {
- System.out.println("Poprawna data");
- }
- assert !"12,12,12".matches(regex);
- assert !"2.10.".matches(regex);
- assert !"120.120.123".matches(regex);
- assert !"nic".matches(regex);
- assert !"127.0.0.1".matches(regex);
- assert !"32.9.2019".matches(regex);
- assert !"30.13.2019".matches(regex);
- assert "1.12.2019".matches(regex);
- assert "1.1.2019".matches(regex);
- assert "01.1.2019".matches(regex);
- assert "01.01.2019".matches(regex);
- */
- // Zadanie 6
- /*
- System.out.print("Podaj s≥owo: ");
- String slowo = in.readLine();
- if (slowo.matches(".*[ \t]+.*")) {
- throw new Exception("Z≥e s≥owo");
- }
- String regex = ".*(?i)" + slowo + ".*";
- String linia = in.readLine();
- if (linia.matches(regex)) {
- System.out.println(linia);
- }
- if (linia.contains(slowo)) {
- System.out.println(linia);
- }
- */
- // Zadanie 7
- /*
- int lessThan20 = 0;
- int counter = 0;
- while (lessThan20 < 10 && counter < 100) {
- long randomNum = Math.round(Math.random() * 100);
- if (randomNum < 20) {
- System.out.println(randomNum);
- lessThan20++;
- }
- counter++;
- }
- */
- // Zadanie 8
- int [][]tablica = {
- { 10 },
- { 12, 14 },
- { 16, 18, 20 },
- { 22, 24, 26, 28 },
- { 30, 32, 34, 36, 38 },
- };
- for (int i = 0; i < tablica.length; i++) {
- for (int j = 0; j < tablica[i].length; j++) {
- System.out.print(tablica[i][j] + " ");
- }
- System.out.println();
- }
- // Zadanie 9
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement