C语言画矩形!修改rectangle(40,i,59,i+10); /*画出左边框*/这句呀!横坐标增加就可以了
用c语言编矩形#include stdio.h
int main(){
int width, height, fill;
char chr;
scanf("%d %d %c %d", height, width, chr, fill);
if(height10 || height3){
perror("Height must between 3 and 10!");
return 1;
}
if(width10 || width5){
perror("Width must between 5 and 10!");
return 1;
}
for(int i=0; iheight; i++){
if(i == 0 || i == height-1 || fill){
for(int j=0; jwidth; j++){
printf("%c", chr);
}
}else{
printf("%c", chr);
for(int j=0; jwidth-2; j++){
printf(" ");
}
printf("%c", chr);
}
printf("\n");
}
return 0;
用c语言画矩形每行起始和结束字符均是你的第3个参数
矩形第1行和最后一行中间是第3个参数,其他行根据第4个参数决定是空格或者第3个参数
程序可以这样写:
...
for ( m=0;ma;m++ )
{
printf("%c",c); //第1列
if ( m==0 || m==a-1 ) //第1行和最后一行
for ( n=1;nb-1;n++ ) printf("%c",c);
else //中间的行
for ( n=1;nb-1;n++ ) if ( d==0 ) printf(" "); else printf("%c",c); //空心或否
printf("%c\n",c); //最后1列
}
或者可以写:
for ( m=0;ma;m++ )
{
printf("%c",c); //第1列
if ( m==0 || m==a-1 || d!=0) for ( n=1;nb-1;n++ ) printf("%c",c);
else for ( n=1;nb-1;n++ ) printf(" ");
printf("%c\n",c); //最后1列
}
C语言怎么画矩形??用lineto函数画矩形
#includegraphics.h
main()
{int gdriver=DETECT,gmode;
initgraph(gdriver,gmode,"c:\\tc");
cleardevice();
moveto(160,120);
lineto(480,120);
lineto(160,360);
lineto(160120);
getch();
closegraph();
}
图形和图像函数包含在graphics.h里面
rectangle() 画矩形函数
功能: 函数rectangle() 用当前绘图色、线型及线宽,画一个给定左上角与右下角的矩形(正方形或长方形) 。
用法: 此函数调用方式为void rectangle(int left,int top,int right,int bottom);
说明: 参数left,top是左上角点坐标,right,bottom是右下角点坐标 。如果有一个以上角点不在当前图形视口内,且裁剪标志clip设置的是真(1) , 那么调用该函数后 , 只有在图形视口内的矩形部分才被画出 。
这个函数对应的头文件为graphics.h
返回值: 无
例: 下面的程序画一些矩形实例:
#i ncludegraphics.h
void main()
{
int driver,mode;
driver=DETECT;
mode=0;
initgrpah(driver,mode,"");
rectangle(80,80,220,200);
rectangle(140,99,180,300);
rectangle(6,6,88,88);
rectangle(168,72,260,360);
getch();
restorecrtmode();
}
用C语言画矩形/*旋转的立体椭球 */
#include graphics.h
#include math.h
#include conio.h
#define PI 3.14159
#define T PI/180
#define NN 36
#define DT PI/NN
#define DIST 0.8
#define R 190
static int n=1;
void trans(t,s)
float t[3];
float s[3][3];
{
s[0][0]=cos(t[1])*cos(t[2]); s[0][1]=cos(t[1])*sin(t[2]);
s[0][2]=-sin(t[1]);
s[1][0]=sin(t[0])*sin(t[1])*cos(t[2])-cos(t[0])*sin(t[2]);
s[1][1]=sin(t[0])*sin(t[1])*sin(t[2])+cos(t[0])*cos(t[2]);
s[1][2]=sin(t[0])*cos(t[1]);
s[2][0]=cos(t[0])*sin(t[1])*cos(t[2])+sin(t[0])*sin(t[2]);
s[2][1]=cos(t[0])*sin(t[0])*sin(t[2])-sin(t[0])*cos(t[2]);
s[2][2]=cos(t[0])*cos(t[1]);
}
void draw(m,da,db)
float m[3][3],da,db;
{
float f[3],f0 , x0,y0,x1,y1,x2,y2;
f[0]=R*sin(da)*cos(db); f[1]=R*sin(da)*sin(db);
f[2]=R*cos(da);
f0=f[0]*m[0][2]+f[1]*m[1][2]+f[2]*m[2][2];
推荐阅读
- 华硕6600配什么cpu,华硕的660p
- wordpress安装淘宝客,wordpress 淘客
- excel图标怎么添加线,excel图中怎么增加一条线
- 直播间利益点文案范本,直播利益点是什么意思
- php查询数据代码怎么写 php查询数据库内容表格
- 各种小程序怎么开通的权限,小程序的权限在哪设置
- html5不能播放mp4视频播放器的简单介绍
- 应用商店哪些射击游戏好,app store好玩的射击游戏
- linux每秒执行命令 linux执行命令时间