
是基础练习吧?
横列像这样输出
pintf("------------------------\n")
纵列就麻烦点,这样输出,你可以连续打多行,也可以用循环来多次输出
pintf("| |\n")
如果要做的好点,伪代码如下,CODE:
for(循环宽度次数){
printf("-")
}
printf("\n")//换行
for(循环高度次数){
printf("|")
for(循环(宽度-2)次数){
printf(" ")
}
printf("|")
printf("\n")//换行
}
for(循环宽度次数){
printf("-")
}
printf("\n")//换行
==================================================
晕……
如此啊
伪代码:
for(i=0;i<20;i++){
printf(i)
if(i==5)
printf("\n")//当i为5的时候换行
}
#include <mathh>
#include <stdioh>
#include <conioh>
#include <stdlibh>
#include <graphicsh>
void polygon(int n, int x, int y, int r, int color, float arg, int fillstyle);
int main()
{
int GraphDriver;
int GraphMode;
float arg = 45, argd;
int a;
int direction;
int r;
int n = 4;
FILE fp;
char szfilename[255] = {"c:\\cubetxt"};
GraphDriver = DETECT;
printf("Input size of cube: ");
scanf("%d", &r);
printf("Input direction(0-1): ");
scanf("%d", &direction);
if (direction == 0)
{
argd = 45;
}
else
{
argd = -45;
}
initgraph(&GraphDriver, &GraphMode, "");
polygon(n, 300, 200, r, 12, arg, 0);
while(1)
{
while(kbhit())
{
a = getch();
if (a == 27)
{
if ((fp = fopen(szfilename, "wt")) != NULL)
{
fprintf(fp, "%d\n%d\n", r, direction);
fclose(fp);
}
closegraph();
return 0;
}
if (a == 0)
{
getch();
polygon(n, 300, 200, r, 0, arg, 0);
arg += argd;
polygon(n, 300, 200, r, 12, arg, 0);
}
else
{
polygon(n, 300, 200, r, 0, arg, 0);
arg += argd;
polygon(n, 300, 200, r, 12, arg, 0);
}
}
}
}
void polygon(int n, int x, int y, int r, int color, float arg, int fillstyle)
{
double pi;
int i;
float x1[10], y1[10];
setcolor(color);
pi = atan(1) 4;
arg = atan(1) / 45 arg;
x1[1] = x + r cos(2 pi / n + arg);
y1[1] = y + r sin(2 pi / n + arg);
moveto(x1[1], y1[1]);
for (i = 2; i <= n; i++)
{
x1[i] = x + r cos(2 pi i / n + arg);
y1[i] = y + r sin(2 pi i / n + arg);
lineto(x1[i], y1[i]);
}
lineto(x1[1], y1[1]);
if (fillstyle != 0)
{
setfillstyle(SOLID_FILL, color);
floodfill(x, y, color);
}
}
#include <stdioh>
#include <stdlibh>
int main()
{
int a,b;
for(a=1;a<6;a++){
for(b=1;b<7;b++)
if (a==1||a==5||b==1||b==6)
printf("");
else
printf(" ");
printf("\n");
}
system("pause");
return 0;
}
以上就是关于C语言如何矩形输出全部的内容,包括:C语言如何矩形输出、用C语言编写程序 在屏幕上画一个矩形、c语言基础"如何用星号画出一个矩形"等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)