• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Day-44:Pattern Program

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Notes1:


package Pattern;

public class Training {
public static void main(String[] args) {
for(int end = 1; end<=5; end++)
{
for(int col = 1; col<=end; col++) //1 2
{
System.out.print(col+" ");
}
System.out.println();
}
}
}

output:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Notes2:


package Pattern;

public class Training2 {
public static void main(String[] args) {
for(int end = 5; end>=1; end--)
{
for(int col = 1; col<=end; col++)
System.out.print(col + " ");
System.out.println();
}
}
}

output:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Notes3:


package Pattern;

public class Training3 {
public static void main(String[] args) {
for(int end = 1; end<=5; end++)
{
for(int col = 1; col<=end; col++)
System.out.print(end+" ");
System.out.println();
}
}
}

output:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Notes4:


package Pattern;

public class Training4 {
public static void main(String[] args) {

for(int row=1; row<=5; row++)
{
for(int col= 1 ; col<=6-row; col++)
{
System.out.print("* ");
}
System.out.println();
}
}
}

output:

  • *

Notes5:


package Pattern;

public class Training5 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(col +" "); // 1 2 3 4 5
}
System.out.println();
}
}
}

output:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Notes6:


package Pattern;

public class Training6 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(row+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}

output:
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5

Notes7:


package Pattern;

public class Training7 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(col*row +" "); // 1 2 3 4 5
}
System.out.println();
}
}
}

output:
1 2 3 4 5
2 4 6 8
3 6 9
4 8
5

notes8:


package Pattern;

public class Training8 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(row+col+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}

output:
2 3 4 5 6
3 4 5 6
4 5 6
5 6
6

notes9:


package Pattern;

public class Training9 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(row+col-1+" ");
}
System.out.println();
}
}
}

output:
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5

Notes10:


package Pattern;

public class Training10 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(6-col+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}

output:
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу