第一次做c语言作业,想了很久但不会。
.编写程序,在屏幕上显示下列图形:
* * * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
用for或while,do-while循环语句实现,求指导,求解。
[解决办法]
#include <iostream>
using namespace std;
int main()
{
for (int i = 9; i > 0; i--) {
for (int j = 0; j < i; j++)
cout << '*';
cout << endl;
}
return 0;
}
#include <stdio.h>
int main(void)
{
int line;
int i;
for(line = 0; line < 9; line++)
{
for(i = 9; i > line; i--)
{
printf("*");
}
printf("\n");
}
return 0;
}