任務是僅使用while
循環打印以下形狀。使用循環打印出三角形
*
**
***
****
*****
******
*******
********
*********
下面的代碼是什麼我已經試過了,但它不工作,遺憾的是:
#include "stdafx.h"//Visual Studio 2015
#include <stdio.h>
#include <stdlib.h>// using for command system("pause") ;
#include <math.h>
int main()
{
int i=0, k=0;
while (i < 10)
{
while (k <= i)
{
printf("*");
k++;
}
printf("\n");
i++;
}
system("pause");
return 0;
}
我不能由我自己調試。任何人都可以爲我調試這個嗎?
移動聲明和初始化到零k'的'* *內的'而(I <10)'環。 – WhozCraig