Commit 827a5e39 by Patryk Czarnik

choinka

parent cad31127
package domowe.r2.z02_choinka;
import java.util.Scanner;
public class Choinka1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Podaj wysokość choinki: ");
int wys = scanner.nextInt();
for(int i = 1; i <= wys; i++) {
for(int j = 1; j <= wys-i; j++) {
System.out.print(" ");
}
for(int j = 1; j <= 2*i-1; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
package domowe.r2.z02_choinka;
import java.util.Scanner;
public class Choinka2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Podaj wysokość choinki: ");
int wys = scanner.nextInt();
int ile_sp = wys;
int ile_gw = 1;
for(int i = 0; i < wys; i++) {
for(int j = 0; j < ile_sp; j++) {
System.out.print(" ");
}
for(int j = 0; j < ile_gw ; j++) {
System.out.print("*");
}
System.out.println();
ile_sp -= 1;
ile_gw += 2;
}
}
}
package domowe.r2.z02_choinka;
import java.util.Scanner;
public class Choinka3 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Podaj wysokość choinki: ");
int wys = scanner.nextInt();
for(int i = 0; i < wys; i++) {
System.out.println(" ".repeat(wys-i) + "*".repeat(2*i+1));
}
}
}
package domowe.r2.z02_choinka;
import java.util.Scanner;
public class Choinka4 {
public static void main(String[] args) {
final String TLO = ".";
final String ZNAK = "^";
Scanner scanner = new Scanner(System.in);
System.out.print("Podaj wysokość choinki: ");
int wys = scanner.nextInt();
for(int i = 0; i < wys; i++) {
System.out.println(TLO.repeat(wys-i) + ZNAK.repeat(2*i+1) + TLO.repeat(wys-i));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment