Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 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.        
  22.         for(liczpoz=0; liczpoz<x; liczpoz++){
  23.         for (liczspac=x-1;liczspac>0;liczspac--){
  24.             System.out.print(" ");
  25.            
  26.         }
  27.         for(liczgw=0; liczgw<iloscgw;liczgw++) {
  28.             System.out.print("*");            
  29.         }          
  30.         iloscgw=iloscgw+2;
  31.         System.out.println();
  32.        
  33.         }        
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement