Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package Czesc2;
  7. import java.util.Scanner;
  8. /**
  9.  *
  10.  * @author Martusia
  11.  */
  12. public class choinka {
  13.     public static void main (String[] args){
  14.         Scanner skaner=new Scanner (System.in);
  15.         System.out.print("Podaj wysokość choinki: ");
  16.         int x=skaner.nextInt();   //wysokość                
  17.         int liczspac; //licznik spacji
  18.         int iloscgw=1; //ilość gwiazdek
  19.         int liczgw; //licznik gwiazdek
  20.         int liczpoz; //licznik poziomów
  21.         int z=x;
  22.        
  23.         for(liczpoz=0; liczpoz<x; liczpoz++){
  24.         for (liczspac=z-1;liczspac>0;liczspac--){
  25.             System.out.print(" ");
  26.            
  27.         }
  28.         for(liczgw=0; liczgw<iloscgw;liczgw++) {
  29.             System.out.print("*");            
  30.         }          
  31.         iloscgw=iloscgw+2;
  32.         System.out.println();
  33.         z--;
  34.        
  35.         }        
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement