C语言编程问题 平行四边形

来源:百度知道 编辑:UC知道 时间:2024/05/17 11:01:45
输入4个点的坐标,判断它们能否构成平行四边形,如果能在屏幕上显示出来

请大家帮帮忙,最好用turboc2做
谢谢了
注意显示图形问题
#include <graphics.h>
#include <conio.h>
#include <stdio.h>
int driver,mode,errorcode;
driver=DETECT;
initgraph(&driver,&mode,"d:\\tc\\bgi");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf(" Graphics error: %s \n ",grapherrormsg(errorcode));
printf(" Press any key to exit! ");
getch();
return;
}
main()
{
double a1,b1,c1,d1,a2,b2,c2,d2;
double x1,y1,x2,y2,x3,x4,y3,y4;
scanf("%f,%f",&x1,&y1);
scanf("%f,%f",&x2,&y2);
scanf("%f,%f",&x3,&y3);
scanf("%f,%f",&x4,&y4);
a1=x1-x2;a2=y1-y2;b1=x2-x3;b2=y2-y3;c1=x3-x4;c2=y3-y4;d1=x4-x1;d2=y4-y1;
if(a1*c2+a2*c1==0&&a1*b2+a2*b1==0)
printf("T");
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);

看来判断是没有问题的,我刚才写了一个,我只把画图的部分给你!
/**************** 初始化图形引擎 ***********/
int driver,mode,errorcode;
driver=DETECT;
initgraph(&driver,&mode,"d:\\tc\\bgi");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf(" Graphics error: %s \n ",grapherrormsg(errorcode));
printf(" Press any key to exit! ");
getch();
return;
}

/*********** 开始作图 分别画四个边 ***********/
line(p1.x,p1.y,p2.x,p2.y);
line(p2.x,p2.y,p3.x,p3.y);
line(p3.x,p3.y,p4.x,p4.y);
line(p4.x,p4.y,p1.x,p1.y);

/********* 关闭图形引擎 **********/
getch();
closegraph();

头文件:
#include <graphics.h>
#include <conio.h>
#include <stdio.h>

#include "stdio.h"

struct pos//定义一个结构体pos,用来记录“点”的信息
{
int