Advertisement
joseleonweb

Untitled

Aug 23rd, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DibuixaTriangle {
  4.   public static void main (String[] args) {
  5.     Scanner lector = new Scanner(System.in);
  6.  
  7.     System.out.print("Quina alçada vols? ");
  8.     int alt = lector.nextInt();
  9.     lector.nextLine();
  10.  
  11.     int numAs = 1;
  12.  
  13.     //Una iteració per línia.
  14.     for(int i = 0; i < alt; i++) {
  15.       //Escribim un cert nombre de lletres 'a'.
  16.       for(int j = 0; j < numAs; j++) {
  17.         System.out.print("a");
  18.       }
  19.       numAs++;
  20.       System.out.println();
  21.     }
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement