Софтуерно Инженерство
Loading...
+ Нов въпрос
svetlakrasteva avatar svetlakrasteva 7 Точки

02. Number Pyramid

Здравейте колеги,

Някой може ли да ми помогне с решението на втора задача от упражнението за вложени цикли - Пирамида от числа.

Прочетоь подсказките, но нямам идея как да управлявам принта.sad

Тагове:
0
Programming Basics with Java
VasilK avatar VasilK 38 Точки

import java.util.Scanner;

public class Piramide_Numbers {

    public static void main(String[] args) {

        Scanner scanner = new Scanner( System.in );

        int n = Integer.parseInt( scanner.nextLine());
        int count = 0;

        for ( int i = 1; i <= n; i++) {

            for ( int k = 1; k <= i; k++ ) {
                count++;
                System.out.printf("%d ", count);
                if (count == n ) return;
            }
            System.out.println();
        }

    }

}

0
svetlakrasteva avatar svetlakrasteva 7 Точки

Благодаря, така печата числата без интервали, но го поправих.

Нямаша да се сетя сама за k <= i.

Успех на изпита.

0
VasilK avatar VasilK 38 Точки

Мерси. На теб също.

0
bekent avatar bekent -4 Точки

Divine Voice Goddess Sign Magic Reading! I'm so eager to share that I've planned a NEW path for you to get completely clear lucidity on the best way to flawlessly incorporate your own Divine Voice Goddess Manifestation Magic into your life! Mercury is the planet named for the Roman God of Money, Magic and Messages! As an individual planet, it depicts the characteristics and characteristics common to YOU at a center level. lady in white sea shore manifestation magic review Its arrangement in your graph uncovers the internal endowments of correspondence that you should use so as to show the enchantment of flourishing, become a cash magnet and even level up your own clairvoyant and instinctive blessings as Mercury was likewise a guide for those traverse to the undetectable domain of soul. Your Divine Voice Goddess Manifestation Magic Reading is intended to uncover the manners by which you NATURALLY and EASILY make your most noteworthy correspondence enchantment to turn into a showing mom. manifestation magic

-1