-2
C++で次のパターンを開発したいと思います。高さと幅のあるC++スターパターン
*
***
*****
*******
*********
***********
*****
*****
*****
*****
*****
*****
*****
*****
*****
printf("Enter trunk height: ");
scanf("%d", &trunk_height);
printf("Enter trunk width: ");
scanf("%d", &trunk_width);
printf("Enter leaves width: ");
scanf("%d", &leaves_width);
TRUNCの高さは= 5
が幅を残し9.
TRUNC幅は11
である私はいくつかのコードを記述したが動作していません。私の問題は、truncの高さを検出する方法と、ユーザーから情報を取得するコードを書く方法です。
int main()
{
int i, j;
int x = 5;
int y = 1;
for(j = 1; j <= 5; j++)
{
for(i = 1; i <= x; i++)
{
cout << " ";
}
x--;
for(i = 1; i <= y; i++)
{
cout << "*";
}
y += 2;
cout << endl;
}
}
だからあなたの質問は何ですか? –