啊哈磊_编程从这里起步
标题:
【第四章第6节】动手试一试 题解
[打印本页]
作者:
sujx
时间:
2015-8-31 02:41
标题:
【第四章第6节】动手试一试 题解
本帖最后由 sujx 于 2015-8-31 02:45 编辑
1、请尝试用while循环打印下面的图形
1.PNG
(3.74 KB, 下载次数: 17)
下载附件
保存到相册
2015-8-31 02:43 上传
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b;
a=1;
while(a<=5)
{
b=1;
while (b<=a)
{
printf("%-1d ",a);
b++;
}
printf("\n");
a++;
}
system("pause");
return 0;
}
[/mw_shl_code]
2、请尝试用while循环打印下面的图形
2.PNG
(4.32 KB, 下载次数: 16)
下载附件
保存到相册
2015-8-31 02:43 上传
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b,s;
a=1;
s=1;
while(a<=5)
{
b=1;
while (b<=a)
{
printf("%-1d ",s);
s++;
b++;
}
printf("\n");
a++;
}
system("pause");
return 0;
}[/mw_shl_code]
作者:
yangyifei
时间:
2017-9-30 13:47
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b,n;
a=1;
scanf("%d",&n);//输入数字:n
system("cls");
while(a<=n)//输出行数:n
{
b=1;
while(b<=a)//输出数的个数为行数
{
printf("%d ",a);
b=b+1;
}
printf("\n");
a=a+1;
}
system("pause");
return 0;
}
作者:
yangyifei
时间:
2017-9-30 13:58
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b,c,n;
a=1;
c=1;
scanf("%d",&n);//输入数字:n
while(a<=n)//输出行数:n
{
b=1;
while(b<=a)//输出数的个数为行数
{
printf("%d ",c);
b++;
c++;//输出数逐个加1
}
printf("\n");
a=a+1;
}
system("pause");
return 0;
}
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2