哪位大侠帮忙修改一下这个C程序

来源:百度知道 编辑:UC知道 时间:2024/06/17 21:47:52
根据输入的n(输入前给出提示Please input n:),在屏幕上显示如下图形(分别为n=1、n=2、n=3时的情况)。
*
* * *
*

*
* * *
* * * * *
* * *
*

*
* * *
* * * * *
* * * * * * *
* * * * *
* * *
*

我写的程序是
#include<stdio.h>
void main()
{
int i,j,p=40,n;
printf("Please input n:");
scanf("%d",&n);
for(i=1;i<=n+1;i++)
{
for(j=1;j<p;j++)
printf(" ");
for(j=1;j<=(2*i-1);j++)
printf("*");
printf("/n");
p--;
}
p=p+2;
for(i=n;i>=1;i++)
{
for(j=1;j<p;j++)
printf(" ");
for(j=1;j<=(2*i-1);j++)
printf("*");
printf("/n");
p++;
}
}
运行有问题,帮忙修改一下吧~~谢谢了~~

#include<stdio.h>
void main()
{
int i,j,p=40,n;
printf("Please input n:");
scanf("%d",&n);
for(i=1;i<=n+1;i++)
{
for(j=1;j<p;j++)
printf(" ");
for(j=1;j<=(2*i-1);j++)
printf("*");
printf("\n"); //是\n不是/n
p--;
}
p=p+2;
for(i=n;i>=1;i--) //这错了~下次仔细点
{
for(j=1;j<p;j++)
printf(" ");
for(j=1;j<=(2*i-1);j++)
printf("*");
printf("\n"); //是\n不是/n
p++;
}
}

You are welcome!