C++ Loopga doir masalalar. Chap Pascal Uchburchagi.

dawroun

Davron

Posted on May 30, 2022

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 ❤️.

💖 💪 🙅 🚩
dawroun
Davron

Posted on May 30, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related