- 论坛徽章:
- 0
|
为什么还要用turbo c,turbo下面的代码怎么转化为vc下面运行,那些用着turbo c的难道不感到很受伤吗??反正我是用不习惯。
下面是一段的turbo下面的代码,求求怎么改变成vc下面的,,,,,,,
就是一个画折线的程序。本人是一个菜鸟,没有怎么接触画图的功能。求指导啊。。。- #include<graphics.h>
- #include<stdlib.h>
- void hDrawk(char c[]);
- void vDrawk(char c[]);
- void Drawfline(int b[]);
- int xs=48,ys=50;
- void main()
- {
- int j;
- int gdriver=DETECT,gmode=0;
- int b[]={1,4,2,5,3,5,1,4,2,3};
- char c[10];
- initgraph(&gdriver,&gmode,""); /*图形方式初始化*/
- setbkcolor(15);
- setcolor(6);
- outtextxy(150,70,"the value along with the month changing!");/*输出字符串*/
- hDrawk(c);
- setcolor(8);
- outtextxy(580,365,"month"); /*输出字符串*/
- vDrawk(c);
- setcolor(8);
- outtextxy(65,70,"value"); /*输出字符串*/
- Drawfline(b);
- getch();
- closegraph(); /*退出图形模式*/
- }
- void hDrawk(char c[]) /*画横坐标*/
- {
- int i,j=65;
- setcolor(8);
- line(65,360,565,360); /*画横坐标轴*/
- settextjustify(1,2); /*设定文本排列方式*/
- for(i=0;i<11;i++)
- {
- line(j,375,j,360); /*画横坐标的刻度*/
- itoa(i,c,10);
- outtextxy(j,380,c);
- j+=xs;
- }
- }
- void vDrawk(char c[]) /*画纵坐标*/
- {
- int i,j=360;
- setcolor(8);
- line(65,80,65,360); /*画纵坐标轴*/
- settextjustify(1,1); /*设定文本排列方式*/
- for(i=0;i<=5;i++)
- {
- line(45,j,65,j); /*画纵坐标的刻度*/
- itoa(i,c,10);
- outtextxy(35,j,c);
- j-=ys;
- }
- }
- void Drawfline(int b[]) /*画折线*/
- {
- int i,j=65;
- setcolor(1); /*设置折线颜色*/
- moveto(j,360-(b[0]*ys)); /*移动光标到(j,310-(b[0]*ystep))处*/
- for(i=0;i<10;i++)
- {
- if(i!=10)
- {
- lineto(j+xs,360-(b[i]*ys)); /*绘制折线*/
- }
- j+=xs;
- }
- }
复制代码 |
|