Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
pub:labprog:20171204 [2017/12/04 16:41]
atrent
pub:labprog:20171204 [2017/12/04 16:41] (current)
atrent
Line 302: Line 302:
  }  }
 } }
 +
 +
 +
 +
 +public class Ricorsione2{
 + public static void main(String arg[]){
 + Scanner in =new Scanner(System.in);​
 + int  x=in.nextInt();​
 + Clessidra(x,​0);​
 +
 +
 +
 +
 + }
 +
 + public static void Clessidra(int n,int off ){
 + if (n==1){
 + for(int i=0;​i<​off;​i++)
 + System.out.print("​ ");
 + System.out.println("​*"​);​
 + }
 + else{
 + for(int i=0;​i<​off;​i++)
 + System.out.print("​ ");
 + for (int i=0;​i<​2*n-1;​i++)
 + System.out.print("​*"​);​
 + System.out.println();​
 + Clessidra(n-1,​off+1);​
 + for(int i=0;​i<​off;​i++)
 + System.out.print("​ ");
 + for (int i=0;​i<​2*n-1;​i++)
 + System.out.print("​*"​);​
 + System.out.println();​
 + }
 +
 + }
 +}
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 </​code>​ </​code>​
pub/labprog/20171204.txt · Last modified: 2017/12/04 16:41 by atrent
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0