Dilyana86

Untitled

Apr 26th, 2017
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class a13NumberPyramid {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. int n = Integer.parseInt(scan.nextLine());
  7. int num = 1;
  8. for(int i=0; i<n ; i++){
  9. for(int j=0; j<n ; j++){
  10. if(i>=j){
  11. System.out.print(num);
  12. System.out.print(" ");
  13. num++;
  14. }
  15. if(num > n){
  16. break;
  17. }
  18. }
  19. System.out.println();
  20. if(num > n){
  21. break;
  22. }
  23. }
  24. }
  25. }
Add Comment
Please, Sign In to add comment