3个回答
展开全部
//输入一个n
#include "stdio.h"
int main()
{
int n;
int count=1;
int lr,middle;
int i;
scanf("%d",&n);
lr=n-1;
middle=n-lr;
while(count<=n)
{
for(i=0;i<lr;i++)
printf(" ");
for(i=0;i<middle;i++)
printf("%d",count);
printf("\n");
count++;
lr--;
middle+=2;
}
count-=2;
lr+=2;
middle-=4;
while(count>0)
{
for(i=0;i<lr;i++)
printf(" ");
for(i=0;i<middle;i++)
printf("%d",count);
printf("\n");
count--;
lr++;
middle-=2;
}
return 0;
}
#include "stdio.h"
int main()
{
int n;
int count=1;
int lr,middle;
int i;
scanf("%d",&n);
lr=n-1;
middle=n-lr;
while(count<=n)
{
for(i=0;i<lr;i++)
printf(" ");
for(i=0;i<middle;i++)
printf("%d",count);
printf("\n");
count++;
lr--;
middle+=2;
}
count-=2;
lr+=2;
middle-=4;
while(count>0)
{
for(i=0;i<lr;i++)
printf(" ");
for(i=0;i<middle;i++)
printf("%d",count);
printf("\n");
count--;
lr++;
middle-=2;
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#define num 2*5+1
int i;
for(i=0;i<num;i++)
{
if(i<=int (num/2))
{
for(j=0;j<(int (num/2)-1-i)*2+1;j++)
printf(" ");
for(j=0;j<(i+1)*2+1;j++)
printf("%d",i+1);
}
else
{
for(j=0;j<(i-int (num/2))*2+1;j++)
printf(" ");
for(j=0;j<2*(int(num/2)-(i-((int(num/2)+1))-1)+1;j++)
printf("%d",int(num/2)-(i-((int(num/2)+1));
}
}
int i;
for(i=0;i<num;i++)
{
if(i<=int (num/2))
{
for(j=0;j<(int (num/2)-1-i)*2+1;j++)
printf(" ");
for(j=0;j<(i+1)*2+1;j++)
printf("%d",i+1);
}
else
{
for(j=0;j<(i-int (num/2))*2+1;j++)
printf(" ");
for(j=0;j<2*(int(num/2)-(i-((int(num/2)+1))-1)+1;j++)
printf("%d",int(num/2)-(i-((int(num/2)+1));
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1 1
3 2
5 3
8 4
9 5
8 4
5 3
3 2
1 1
3 2
5 3
8 4
9 5
8 4
5 3
3 2
1 1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询