當前位置:首頁 » 編程語言 » 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)