程序输出字符乱码为正方形
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr(); //to clear the screen
printf(“Enter size of the square:”);
scanf(“%d”,&n);
for(i=0;i<n;++i)
{
printf(“n”);
for(j=0;j<n;++j)
{
if(i==0||i==n-1||j==0||j==n-1)
printf(“*”);
else
printf(” “);
}
}
getch(); //to stop the screen
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr(); //to clear the screen
printf(“Enter size of the square:”);
scanf(“%d”,&n);
for(i=0;i<n;++i)
{
printf(“n”);
for(j=0;j<n;++j)
{
if(i==0||i==n-1||j==0||j==n-1)
printf(“*”);
else
printf(” “);
}
}
getch(); //to stop the screen
}
翻译自: https://www.thecrazyprogrammer.com/2012/07/c-program-to-print-following-square_25.html
程序输出字符乱码为正方形
本文介绍了一段使用C语言编程的代码,该代码能够根据用户输入的大小,在控制台上绘制一个空心的正方形。通过双重循环和条件判断,程序实现了正方形的边框由星号(*)构成,而内部为空白。

403

被折叠的 条评论
为什么被折叠?



