c语言bar函数公式 c++ bar

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 坐标 。
麻烦采纳一下 。
用c语言绘制直方图 。。。急急急 。。。。。。答案追加 。。。。。#include graphics.h
#include stdlib.h
#include conio.h
#include stdio.h
void main()
{
int driver=EGA,mode=1;
int data[]={7,3,12,6,9,5,8,11};
int i,j,xstep=70,ystep=20;
char buffer[10];
initgraph (driver,mode,"");
line(40,10,40,310);
line(40,310,540,310);
j=310;
settextjustify(CENTER_TEXT,CENTER_TEXT);
for(i=0;i=15;i)
{line(20,j,40,j);
itoa(i,buffer,10);
outtextxy(10,j,buffer);
j-=ystep;
}
j=40;
settextjustify(CENTER_TEXT,TOP_TEXT);
for(i=0;i=8;i)
{
setfillstyle(i 1,i 4);
line(j,320,j,310);
itoa(i,buffer,10);
outtextxy(j,330,buffer);
if(i!=8)
{
bar(j,(310-(data[i]*ystep)),j xstep,310-1);
rectangle(j,(310-data[i]*ystep),j xstep,310);
}
j =xstep;
}
getch();
closegraph();
}
c语言bar函数怎么用?bar函数:
功 能: 画一个二维条形图
用 法: void far bar(int left,int top,int right,int bottom);
程序例:
#include graphics.h
#include stdlib.h
#include stdio.h
#include conio.h
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⑴; /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* loop through the fill patterns */
for (i=SOLID_FILL; iUSER_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语言的bar()函数和 rectangle()函数bar画一个填充矩形填充颜色由 setfillstyle决定
rectangle画一个空矩形框 , 线条颜色由setcolor决定
C语言中的颜色和边框的函数怎么来运用···if(c=='-')
{
if(strcmp(str2,"")==0) /*如果str2为空,说明是负号,而不是减号*/
flag=-1; /*设置负数标志*/
else
{
【c语言bar函数公式 c bar】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=key0xff? key0xff:key8; /*只取特殊键的扫描值,其余为0*/
return(key); /*返回键值*/
}
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语言bar函数公式和cbar的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息 , 记得收藏关注本站 。

    推荐阅读