这个程序为什么star>20后还要循环啊
#include
using namespace std;
int main()
{
int space, star = 0;
while (star < 20)
{
cout << "输入第一行*个数:";
cin >> star;
for (space = 0; star > 0; star -= 2, space++)
{
for (int i = 1; i <= space; i++)
cout << ' ';
for (int i = 1; i <= star; i++)
cout << '*';
cout << "\n";
}
}
system("pause");
return 0;
}
但是多定义n作为while(n<20)
在 读取了star后 令 n=star 运行又正常了
#include
using namespace std;
int main()
{
int space, n = 0,star;
while (n < 20)
{
cout << "输入第一行*个数:";
cin >> star;
n = star;