-1
即時知道,做而輸出的模式必須是相同的例子
是更多鈔票來此for loop
裏面for loop
轉換爲do while loop
?
這裏是代碼:
int i, j, rows;
printf("Enter number of rows: ");
scanf("%d",&rows);
for(i=1; i<=rows; ++i)
{
for(j=1; j<=i; ++j)
{
printf("* ");
}
printf("\n");
}
這裏是我已經試過:
int i, j, rows;
printf("Enter number of rows: ");
scanf("%d",&rows);
i=1;
j=1;
do {
printf("* ");
i<=rows;
++i;
++j;
} while (j<=i);
printf("\n");
getch();
return 0;
}
試圖盡我所能,但沒有運氣。 順便說一句,我試圖做一個明星模式使用do while loop
任何幫助將不勝感激。
爲什麼?循環是一個循環。如果'for'循環有意義,則使用'for'循環。無論如何,你會得到一個'do while'循環,就像'for'循環一樣。 –
但我需要遵循一條規則。它說我需要使用while while循環而不是for循環 –