ネストされた for ループの動作を理解する途中で、入力を受け取り、その入力値までのピラミッドを次のように表示するプログラムを作成しました。
1
22
333
4444
ピラミッドの高さだけを表示していますが、2番目のforループで書かれた部分を表示していません。
これがコードです(変更後ですが、必要な結果はまだありません)
#include <iostream>
using namespace std;
int main(void)
{
int num;
cout << "Enter the number of pyramid" << endl ;
cin >> num ;
for (int i = 0; i < num ; i++)
{
int max;
for (int j = 0 ; j <= max ; j++)
{
cout << j ;
}
cout << endl ;
max++ ;
}
system("PAUSE");
return 0;
}