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

c语言坐标图

发布时间: 2022-01-14 23:15:25

c语言 坐标

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int xmax, ymax;
initgraph(&gdriver, &gmode, ""); \*初试化图形*/

errorcode = graphresult();

if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}

setcolor(getmaxcolor()); \*可以选择颜色比如color(2)是一种颜色*/
xmax = getmaxx();
ymax = getmaxy();

line(0, 0, xmax, ymax);

getch();
closegraph();
return 0;
}
自己远行一下看看就明白了

⑵ 有可以将C语言输出的坐标画成坐标图的软件吗

TC有一套绘图库,好像就叫graphics.h

如果是VC,就在onpaint或ondraw里用dc就可以画图。

⑶ c语言坐标系怎么编写

用(x,300-y)来表示,则就是表示横坐标在距离显示器顶端300个像素的地方。c语言中一般是在显示器的中央附近吧,因为c语言中显示VGA好像是640*480。当然300是可以改的,任何一个都可以,视情况而定。

⑷ 求教高手:怎么用C语言画坐标图

用graphics。h 里面的画图函数···
至于 怎么样读excel,你网络一下

用vc写比较好点

⑸ C语言编程坐标曲线

下面是的是昨天的,但是修改了一下坐标的刻度.

/*******************************************************
*Author :Wacs5
*Date :20090105(YYYY-MM-DD)
*Function :画简易的曲线图 *********************************************************/
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <math.h>
#include <Graphics.h>

#define n 8

int main()
{
int i,j;
float data[]={7,3,12,6,9,5,8,11};
char str[40];

int gdrive=DETECT,gmode,errorcode;
int maxx,maxy;
int perx,pery;
int x0,x1,y0,y1;
int coloraxis=2,colorline=3;
float mindata,maxdata,ndata;

initgraph(&gdrive,&gmode,""); /*初始化设备*/
if ((errorcode=graphresult())!=grOk) /*查错*/
{
printf("Graphics error:%s\nPress any key to exit:",grapherrormsg(errorcode));
getch();
exit(1);
}
maxx=getmaxx();
maxy=getmaxy();
mindata=0;
maxdata=data[0];
for (i=1;i<n;i++)
if (maxdata<data[i])
maxdata=data[i];

perx=maxx/(n+4);
pery=maxy/(maxdata-mindata+4);
x0=2*perx;
y0=maxy-2*pery;

x1=maxx-2*perx;
y1=2*pery;
setcolor(coloraxis);
line(x0,y0,x1,y0);
line(x0,y0,x0,y1);

line(x1,y0,x1-4,y0+3);
line(x1,y0,x1-4,y0-3);
line(x0,y1,x0+3,y1+4);
line(x0,y1,x0-3,y1+4);

settextjustify(CENTER_TEXT,TOP_TEXT);
for (i=0;i<=n;i++)
{
j=x0+i*perx;
line(j,y0,j,y0+2); /*刻度线*/
sprintf(str,"%d",i);
outtextxy(j,y0+4,str);
}

settextjustify(RIGHT_TEXT,CENTER_TEXT);
for (i=1;i<=12;i++)
{
j=y0-i*pery;
line(x0,j,x0-2,j); /*刻度线*/
sprintf(str,"%d",i);
outtextxy(x0-4,j,str);
}

setcolor(colorline);
x1=x0+perx;
y1=y0-(data[0]-mindata)*pery;
circle(x1,y1,2);
moveto(x1,y1);
i=1;
do
{
x1+=perx;
y1=y0-(data[i]-mindata)*pery;
lineto(x1,y1);
circle(x1,y1,2);
moveto(x1,y1);
i++;
}while(i<n);

getch();
closegraph();
return 0;
}

⑹ c语言怎么在坐标上画y=a0+bx1+cx2的图

你可以遍历你所要求的x所在的区间,设置好采样的频率。然后循环求出y。并把x,y做为坐标点存储缓存中。最后按你想要的表示方式,画出坐标点。

⑺ c语言编出的图形如直线是以左上角为(0,0)点如何调整成符合习惯的坐标系

c语言本身是无法调整的,但是如果为了使用原点为左下角的坐标系完全可以用坐标变

换实现,你只需要自己写一个自己的直线函数,即参数为以左下角为原点的直线的端点

的直线函数。并在函数中作一次坐标变换就可以了,举个例子:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
/*直线函数*/
void myline(int x1, int y1, int x2, int y2)
{
int ymax = getmaxy(); /*获得屏幕最低点的y坐标*/
y1 = ymax - y1; /*坐标变换*/
y2 = ymax - y2;
line(x1, y1, x2, y2);
}
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int xmax, ymax;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "h:\\work\\tc3\\bgi");

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

setcolor(getmaxcolor());
xmax = getmaxx();
ymax = getmaxy();

/* 这是原来的直线函数*/
line(0, 0, xmax, ymax);
/* 这是变换后的直线函数*/
myline(0,0,xmax,ymax);
/* clean up */
getch();
closegraph();
return 0;
}

不过不推荐使用这种方法,其实,坐标原点在哪里都是一样的,用习惯就好了。

⑻ C语言如何画以一维数组为横坐标,和纵坐标的图

dimp(b.length-1)aspoint
foriasinteger=0tob.length-1
p(i).x=b(i)
p(i).y=h-a(i)'这里h是你要绘制曲线的控件的高度
next

然后在窗体或者picturebox的paint事件中:
'画笔
DimblackPenAsNewPen(Color.Black)

'绘制曲线
e.Graphics.DrawLines(blackPen,p)