Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package Czesc2;
- import java.util.Scanner;
- /**
- *
- * @author Martusia
- */
- public class choinka {
- public static void main (String[] args){
- Scanner skaner=new Scanner (System.in);
- System.out.print("Podaj wysokość choinki: ");
- int x=skaner.nextInt(); //wysokość
- int liczspac; //licznik spacji
- int iloscgw=1; //ilość gwiazdek
- int liczgw; //licznik gwiazdek
- int liczpoz; //licznik poziomów
- for(liczpoz=0; liczpoz<x; liczpoz++){
- for (liczspac=x-1;liczspac>0;liczspac--){
- System.out.print(" ");
- }
- for(liczgw=0; liczgw<iloscgw;liczgw++) {
- System.out.print("*");
- }
- iloscgw=iloscgw+2;
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement