C语言一道简单例题

来源:百度知道 编辑:UC知道 时间:2024/05/12 16:49:05
1
12
123
1234
12345
123456
1234567
123456789
12345678
1234567
123456
12345
1234
123
12
1
编写程序用printf 打印出来

void main()
{
int i,j;
for(i=1;i<=9;++i)
{
{ for(j=1;j<=i;++j)
printf("%d",j);
}
printf("\n");
}
for(i=8;i>=1;--i;)
{
{
for(j=8;j>=1;--j)
printf("%d",j);
}
printf("\n");
}
}

你去试试。好久没碰C了,有可能有的地方语法不对

#include<stdio.h>
void main()
{
int i,j;
for(i=1;i<=9;++i)
{
{ for(j=1;j<=i;++j)
printf("%d",j);
}
printf("\n");
}
for(i=8;i>=1;--i)
{
{
for(j=1;j<=i;++j)
printf("%d",j);
}
printf("\n");
}
}
//vc6.0下编译运行通过

#include "stdio.h"
main()
{
int i,j;
for(j=1;j<=9;j++)
{
for(i=1;i<=j;i++)
printf("%d",i);
printf("\n");
}
for(j=8;j>0;j--)