DEV Community

Davron
Davron

Posted on

3 2

C++ Loopga doir masalalar. Chap Pascal Uchburchagi.

Raqamlardan foydalanib Chap Pascal Uchburchagini chop etish.

Natija (inputga 7 kiritildi deb tasavvur qilinsin):

            1 
          1 2 
        1 2 3 
      1 2 3 4 
    1 2 3 4 5 
  1 2 3 4 5 6 
1 2 3 4 5 6 7 
  1 2 3 4 5 6 
    1 2 3 4 5 
      1 2 3 4 
        1 2 3 
          1 2 
            1       
Enter fullscreen mode Exit fullscreen mode

Kod:


    cout << "Chap Paskal Uchburchagi qatorlari sonini kiriting = ";
    cin >> qatorlar;

    cout << "Chap Paskal Uchburchak shakli\n"; 

    for(i = 1; i <= qatorlar; i++)
    {
        for(j = i; j < qatorlar; j++)
            {
          cout << "  ";
        }
        for(k = 1; k <= i; k++)
          {
            cout << k << " ";
          }
        cout << "\n";
    }   

    for(i = qatorlar; i >= 1; i--)
    {
        for(j = i; j <= qatorlar; j++)
        {
            cout << "  ";
        }
        for(k = 1; k < i; k++)
        {
            cout << k << " ";
        }
        cout << "\n";
    }

    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Savol va Takliflar uchun Telegram ❤️.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay