当前位置:首页 » 编程语言 » c语言的bar函数
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言的bar函数

发布时间: 2022-11-03 00:42:05

c语言的画图函数除了bar函数外还有哪些

与图形有关的函数
GRAPHICS.H 库文件

bar
【功能】画出一条栏目。
【原型】void far bar(int left,int top,int right,int bottom)
【位置】graphics.hgraphics.h
【参见】bar3d,setfillstyle,rectangle
bar3d
【功能】画出一条3-D栏目。
【原型】void far bar3d(int left,int top,int right,int bottom,int depth,int topflag)
【位置】graphics.h
【参见】bar
circle
【功能】以(x,y)为圆心按照指定的半径画出一个圆。
【原型】void far circle(int x,int y,int radius)
【位置】graphics.h
【参见】arc
cleardevice
【功能】清除图形画面。
【原型】void far cleardevice(void)
【位置】graphics.h
【参见】clearviewport
clearviewport
【功能】清除当前可视区域。
【原型】clearviewport(void)
【位置】graphics.h
【参见】setviewport,cleardevice
closegraph
【功能】关闭图形系统。
【原型】void far closegraph(void)
【位置】graphics.h
【参见】initgraph
detecgraph
【功能】通过检查硬件确定使用的图形驱动程序和模式。
【原型】void far detectgraph(int far *graphdriver,int far *graphmode)
【位置】graphics.h
【参见】initgraph,graphresult
drawpoly
【功能】画出一个多边形的轮廓。
【原型】void far drawpoly(int numpoints,int far polypoints[])
【位置】graphics.h
【说明】polypoints中包括一共numpoints对数值。其中每一对都给出了多边形中一个顶点的x和y值。
【参见】fillpoly
ellipse
【功能】画出一条椭圆形的圆弧。
【原型】void far ellipse(int x,int y,int stangle,int endangle,int xradius,int yradius)
【位置】graphics.h
【说明】中心点在(x,y),stangle和endangle表示一角度为单位的起始角和终止角。Xradius和yradius表示水平轴和垂直轴。
【参见】arc,circle,fillellipse
fillellipose
【功能】画出椭圆形圆弧,并填充。
【原型】void far fillllipse(int x,int y,int xradius,int yradius)
【位置】graphics.h
【说明】使用(x,y)作为中心点,然后使用当前的填充模式填充圆弧。Xradius和yradius表示水平轴和垂直轴。
【参见】arc,circle,ellipse,pieslice
fillpoly
【功能】画出一个多边形,并填充。
【原型】void far fillpoly(int numpoints,int far polypoints[])
【位置】graphics.h
【说明】polypoints中包含有numpoints对数值。其中每一对给出了多边形一个顶点的x值和y值。
【参见】drawpoly,fill_patterns,floodfill,graphresult,setfillstyle
floodfill
【功能】填充一个有界区域范围。
【原型】void far floodfill(int x,int y,int border)
【位置】graphics.h
【参见】drawpoly,fillpoly,fill_patterns,graphresult,setfillstyle
getarccoords
【功能】得到最后一次调用arc的坐标值。
【原型】void far getaerccoords(struct arccoordstype far *arccoords)
【位置】graphics.h
【参见】arc
getaspectratio
【功能】得到当前图形模式的纵横比。
【原型】void far getaspectratio(int far *xasp,int far *yasp)
【位置】graphics.h
【说明】are及类似函数使用纵横比令圆圈更加圆,而不会像椭圆。Yasp应当为10000。当象素为<VGA>平方并且<10000时,xasp使用10000数值。
【参见】arc,setaspectratio
getbkcolor
【功能】返回当前背景颜色。
【原型】int far getbkcolor(void)
【位置】graphics.h
【参见】setbkcolor,getcolor,getpalette
getcolor
【功能】返回当前画笔的颜色。
【原型】int far getcolor(void)
【位置】graphics.h
【参见】getbkcolor,setcolor,getmaxcolor,getpalette
getdefaultpalette
【功能】返回调色板定义结构。
【原型】struct palettetype *far getdefaultpalette(void)
【位置】graphics.h
【说明】返回一个指针,指向调用initgraph初始化时,当前驱动程序的默认调色板结构。
【参见】getpalette,initgraph
getdrivername
【功能】返回一个指针,指向当前图形驱动程序的名称。
【原型】char *far getdrivername(void)
【位置】graphics.h
【说明】返回的指针指向标识当前驱动器程序的字符串,从而可以探测到硬件适配器。
【参见】initgraph
getfillpattern
【功能】将用户定义的填充模式复制到内存中。
【原型】void far getfillpattern(char far *pattern)
【位置】graphics.h
【参见】getfillsettings,setfillpattern,fill_patterns
getfillsettings
【功能】得到当前填充模式及其颜色的有关信息。
【原型】void far getfillsettings(struct fillsettingstype far *fillinfo)
【位置】graphics.h
【参见】floodfill, fillpoly, setfillstyple, pieslice, setfillpattern, bar3d, bar, getfillpattern
getgraphmode
【功能】返回当前图形模式。
【原型】int far getgraphmode(void)
【位置】graphics.h
【说明】必须先调用initgraph或者setgraphmode。
【参见】setmoderange,restorectrtmode
getimage
【功能】将制定区域的位图保存到内存中。
【原型】void far getimage(int left,int top,int right,int bottom,void far *bitmap)
【位置】graphics.h
【参见】imagesize,putimage

因为太多了,无法一一列出。比如下面的:
putimage

putpixel

rectangle

registerbgidriver

registerbgifont

restorecrtmode

sector

setactivepage

setallpalette

setaspectratio

setbkcolor

setcolor

setfillpattern

setfillstyle

setgraphbufsize

setgraphmode

setlinestyle

setpalette

setrgbcolor

setrgbpalette

settextjustify

settextstyle

setusercharsize

setviewport
setvisualpage

setwritemode

textheight

textwidth

建议你买本专业的书籍学习查看。

⑵ C语言中的栈、堆是什么

C语言中的堆和栈都是一种数据项按序排列的数据结构。

栈就像装数据的桶或箱子

我们先从大家比较熟悉的栈说起吧,它是一种具有后进先出性质的数据结构,也就是说后存放的先取,先存放的后取。

这就如同我们要取出放在箱子里面底下的东西(放入的比较早的物体),我们首先要移开压在它上面的物体(放入的比较晚的物体)。

堆像一棵倒过来的树

而堆就不同了,堆是一种经过排序的树形数据结构,每个结点都有一个值。

通常我们所说的堆的数据结构,是指二叉堆。堆的特点是根结点的值最小(或最大),且根结点的两个子树也是一个堆。

由于堆的这个特性,常用来实现优先队列,堆的存取是随意,这就如同我们在图书馆的书架上取书。

虽然书的摆放是有顺序的,但是我们想取任意一本时不必像栈一样,先取出前面所有的书,书架这种机制不同于箱子,我们可以直接取出我们想要的书。

(2)c语言的bar函数扩展阅读:

关于堆和栈区别的比喻

使用栈就象我们去饭馆里吃饭,只管点菜(发出申请)、付钱、和吃(使用),吃饱了就走,不必理会切菜、洗菜等准备工作和洗碗、刷锅等扫尾工作,他的好处是快捷,但是自由度小。

使用堆就象是自己动手做喜欢吃的菜肴,比较麻烦,但是比较符合自己的口味,而且自由度大。

参考资料来源:网络-堆栈



⑶ C语言中的图形函数有哪些

一) 像素函数
putpiel() 画像素点函数
getpixel()返回像素色函数
(二) 直线和线型函数
line() 画线函数
lineto() 画线函数
linerel() 相对画线函数
setlinestyle() 设置线型函数
getlinesettings() 获取线型设置函数
setwritemode() 设置画线模式函数
(三)、多边形函数
rectangle() 画矩形函数
bar() 画条函数
bar3d() 画条块函数
drawpoly() 画多边形函数
(四)、 圆、弧和曲线函数
getaspectratio()获取纵横比函数
circle()画圆函数
arc() 画圆弧函数
ellipse()画椭圆弧函数
fillellipse() 画椭圆区函数
pieslice() 画扇区函数
sector() 画椭圆扇区函数
getarccoords()获取圆弧坐标函数
(五)、 填充函数
setfillstyle() 设置填充图样和颜色函数
setfillpattern() 设置用户图样函数
floodfill() 填充闭域函数
fillpoly() 填充多边形函数
getfillsettings() 获取填充设置函数
getfillpattern() 获取用户图样设置函数
(六)、图像函数
imagesize() 图像存储大小函数
getimage() 保存图像函数
putimage() 输出图像函数

⑷ C语言程序里"BAR"是什么意思

函数名: bar
功 能: 画一个二维条形图
用 法: void far bar(int left, int top, int right, int bottom);
程序例:

#include
#include
#include
#include

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy, i;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

midx = getmaxx() / 2;
midy = getmaxy() / 2;

/* loop through the fill patterns */
for (i=SOLID_FILL; i
{
/* set the fill style */
setfillstyle(i, getmaxcolor());

/* draw the bar */
bar(midx-50, midy-50, midx+50,
midy+50);

getch();
}

/* clean up */
closegraph();
return 0;
}

⑸ c语言 函数名: bar3d 怎么用

bar3d是Turbo C工具中绘制长方体(也可理解为绘制三维条形图)的一个图形函数。其基本语法如下:

bar3d(int left, int top, int right, int bottom, int depth, int topflag);

其中:int left, int top构成第一个坐标点,即屏幕中长方体前面(即离我们最近的长方形)左上角的一个点;

int right, int bottom构成第二个坐标点,即屏幕中长方体前面(即离我们最近的长方形)右下角的一个点;

由以上两个坐标点就可以确定一个长方形,然后结合int depth(用于确定长方体的厚度,即长方体前后两个面的间距),就可以完全确定长方体的形状。

int topflag 用于对长方体的顶部显示方式。

举例:例如在Turbo C++工具中编写的C程序:

# include <graphics.h>

# include <stdio.h>

void main()

{

int graphdriver=DETECT, graphmode;

initgraph(&graphdriver,&graphmode,"C:\TURBOC3\BGI"); //*图形系统初始化*/

bar3d(0,0,250,250,10,1);

getch() ;

closegraph(); // 关闭图形模式//

}

其运行结果为:


运行结果

⑹ C语言中的颜色和边框的函数怎么来运用···

if(c=='-')
{
if(strcmp(str2,"")==0) /*如果str2为空,说明是负号,而不是减号*/
flag=-1; /*设置负数标志*/
else
{
num1=atof(str2); /*将第二个操作数转换为浮点数*/
strcpy(str2,""); /*将str2清空*/
act=2; /*做计算减法标志值*/
setfillstyle(SOLID_FILL,color+3);
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*画矩形*/
outtextxy(5*width,height,"0."); /*显示字符串*/
}
}
if(c=='*')
{
num1=atof(str2); /*将第二个操作数转换为浮点数*/
strcpy(str2,""); /*将str2清空*/
act=3; /*做计算乘法标志值*/
setfillstyle(SOLID_FILL,color+3); bar(2*width+width/2,height/2,15*width/2,3*height/2);
outtextxy(5*width,height,"0."); /*显示字符串*/
}
if(c=='/')
{
num1=atof(str2); /*将第二个操作数转换为浮点数*/
strcpy(str2,""); /*将str2清空*/
act=4; /*做计算除法标志值*/
setfillstyle(SOLID_FILL,color+3);
bar(2*width+width/2,height/2,15*width/2,3*height/2);
outtextxy(5*width,height,"0."); /*显示字符串*/
}
if(c=='^')
{
num1=atof(str2); /*将第二个操作数转换为浮点数*/
strcpy(str2,""); /*将str2清空*/
act=5; /*做计算乘方标志值*/
setfillstyle(SOLID_FILL,color+3); /*设置用淡绿色实体填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*画矩形*/
outtextxy(5*width,height,"0."); /*显示字符串*/
}
if(c=='%')
{
num1=atof(str2); /*将第二个操作数转换为浮点数*/
strcpy(str2,""); /*将str2清空*/
act=6; /*做计算模运算乘方标志值*/
setfillstyle(SOLID_FILL,color+3); /*设置用淡绿色实体填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*画矩形*/
outtextxy(5*width,height,"0."); /*显示字符串*/
}
if(c=='=')
{
num2=atof(str2); /*将第二个操作数转换为浮点数*/
switch(act) /*根据运算符号计算*/
{
case 1:result=num1+num2;break; /*做加法*/
case 2:result=num1-num2;break; /*做减法*/
case 3:result=num1*num2;break; /*做乘法*/
case 4:result=num1/num2;break; /*做除法*/
case 5:result=pow(num1,num2);break; /*做x的y次方*/
case 6:result=fmod(num1,num2);break; /*做模运算*/
}
setfillstyle(SOLID_FILL,color+3); /*设置用淡绿色实体填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆盖结果区*/
sprintf(temp,"%f",result); /*将结果保存到temp中*/
outtextxy(5*width,height,temp); /*显示结果*/
}
if(c=='c')
{
num1=0; /*将两个操作数复位0,符号标志为1*/
num2=0;
flag=1;
strcpy(str2,""); /*将str2清空*/
setfillstyle(SOLID_FILL,color+3); /*设置用淡绿色实体填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆盖结果区*/
outtextxy(5*width,height,"0."); /*显示字符串*/
}
if(c=='Q')exit(0); /*如果选择了q回车,结束计算程序*/
}
putimage(x,y,rar,XOR_PUT); /*在退出之前消去光标箭头*/
return; /*返回*/
}
/*窗口函数*/
void mwindow( char *header )
{
int height;
cleardevice(); /* 清除图形屏幕 */
setcolor( MaxColors - 1 ); /* 设置当前颜色为白色*/
setviewport( 20, 20, MaxX/2, MaxY/2, 1 ); /* 设置视口大小 */
height = textheight( "H" ); /* 读取基本文本大小 */
settextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );/*设置文本样式*/
settextjustify( CENTER_TEXT, TOP_TEXT );/*设置字符排列方式*/
outtextxy( MaxX/4, 2, header ); /*输出标题*/
setviewport( 20,20+height+4, MaxX/2+4, MaxY/2+20, 1 ); /*设置视口大小*/
drawboder(); /*画边框*/
}
void drawboder(void) /*画边框*/
{
struct viewporttype vp; /*定义视口类型变量*/
setcolor( MaxColors - 1 ); /*设置当前颜色为白色 */
setlinestyle( SOLID_LINE, 0, NORM_WIDTH );/*设置画线方式*/
getviewsettings( &vp );/*将当前视口信息装入vp所指的结构中*/
rectangle( 0, 0, vp.right-vp.left, vp.bottom-vp.top ); /*画矩形边框*/
}
/*设计鼠标图形函数*/
int arrow()
{
int size;
int raw[]={4,4,4,8,6,8,14,16,16,16,8,6,8,4,4,4}; /*定义多边形坐标*/
setfillstyle(SOLID_FILL,2); /*设置填充模式*/
fillpoly(8,raw); /*画出一光标箭头*/
size=imagesize(4,4,16,16); /*测试图象大小*/
rar=malloc(size); /*分配内存区域*/
getimage(4,4,16,16,rar); /*存放光标箭头图象*/
putimage(4,4,rar,XOR_PUT); /*消去光标箭头图象*/
return 0;
}
/*按键函数*/
int specialkey(void)
{
int key;
while(bioskey(1)==0); /*等待键盘输入*/
key=bioskey(0); /*键盘输入*/
key=key&0xff? key&0xff:key>>8; /*只取特殊键的扫描值,其余为0*/
return(key); /*返回键值*/
}

⑺ c语言的图形函数库有哪些

图形和图像函数包含在graphics.h里面

(一) 像素函数
56. putpiel() 画像素点函数
57. getpixel()返回像素色函数
(二) 直线和线型函数
58. line() 画线函数
59. lineto() 画线函数
60. linerel() 相对画线函数
61. setlinestyle() 设置线型函数
62. getlinesettings() 获取线型设置函数
63. setwritemode() 设置画线模式函数
(三)、多边形函数
64. rectangle() 画矩形函数
65. bar() 画条函数
66. bar3d() 画条块函数
67. drawpoly() 画多边形函数
(四)、 圆、弧和曲线函数
68. getaspectratio()获取纵横比函数
69. circle()画圆函数
70. arc() 画圆弧函数
71. ellipse()画椭圆弧函数
72. fillellipse() 画椭圆区函数
73. pieslice() 画扇区函数
74. sector() 画椭圆扇区函数
75. getarccoords()获取圆弧坐标函数
(五)、 填充函数
76. setfillstyle() 设置填充图样和颜色函数
77. setfillpattern() 设置用户图样函数
78. floodfill() 填充闭域函数
79. fillpoly() 填充多边形函数
80. getfillsettings() 获取填充设置函数
81. getfillpattern() 获取用户图样设置函数
(六)、图像函数
82. imagesize() 图像存储大小函数
83. getimage() 保存图像函数
84. putimage() 输出图像函数

四、图形和图像函数
对许多图形应用程序,直线和曲线是非常有用的。但对有些图形只能靠操作单个像素才能画出。当然如果没有画像素的功能,就无法操作直线和曲线的函数。而且通过大规模使用像素功能,整个图形就可以保存、写、擦除和与屏幕上的原有图形进行叠加。
(一) 像素函数

56. putpixel() 画像素点函数
功能: 函数putpixel() 在图形模式下屏幕上画一个像素点。
用法: 函数调用方式为void putpixel(int x,int y,int color);
说明: 参数x,y为像素点的坐标,color是该像素点的颜色,它可以是颜色符号名,也可以是整型色彩值。
此函数相应的头文件是graphics.h
返回值: 无
例: 在屏幕上(6,8)处画一个红色像素点:
putpixel(6,8,RED);

57. getpixel()返回像素色函数
功能: 函数getpixel()返回像素点颜色值。
用法: 该函数调用方式为int getpixel(int x,int y);
说明: 参数x,y为像素点坐标。
函数的返回值可以不反映实际彩色值,这取决于调色板的设置情况(参见setpalette()函数)。
这个函数相应的头文件为graphics.h
返回值: 返回一个像素点色彩值。
例: 把屏幕上(8,6)点的像素颜色值赋给变量color。
color=getpixel(8,6);

⑻ c语言的bar()函数和 rectangle()函数

bar画一个填充矩形 填充颜色由 setfillstyle决定
rectangle画一个空矩形框,线条颜色由setcolor决定

⑼ C语言 easyx里面 bar(120,130,340,250)具体是什么意思只知道bar是画

你好,这里是bar的详细参数说明:
bar
这个函数用于画无边框填充矩形。
void bar(int left,int top,int right,int bottom);
参数:
left矩形左部 x 坐标。
top矩形上部 y 坐标。
right矩形右部 x 坐标。
bottom矩形下部 y 坐标。

麻烦采纳一下。