本帖最后由 心跳為你 于 2010-3-13 16:28 编辑 #include <stdio.h>
main(){
int i,j,n,m;
printf("please input a odd number:\n");
scanf("%d",&n);
m=(n+1)/2;
printf("\n\nThe result is like this:\n");
for(j=1;j<=n;j++)
{
for(i=1;i<=n;i++)
{
if(j==m||i==m)
printf("*");
else printf(" ");
}
printf("\n");
}
}
#include <stdio.h>
int odd(int n)
{
int i,j,m;
m=(n+1)/2;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i==m||j==m)
printf("*");
else
printf(" ");
}
printf("\n");
}
}
main(){
int n;
printf("please input a odd number:\n");
scanf("%d",&n);
printf("\n\nThe result is like this:\n");
odd(n);
}
|