
多边形读取
������������������ ������������������������ ������������������ ������������������ ������������������������ ������������������ ������������������
发布日期:2021-05-10 05:58:53
浏览次数:29
分类:精选文章
本文共 2028 字,大约阅读时间需要 6 分钟。
���������������������
������������
#include#include #include
������������
#define DATA_SIZE 1024typedef struct { double x; double y;} Point;typedef struct { char name[20]; Point point1; union { Point point2; double Radius; } cate; struct Polygon *next;} Polygon;
������������
int main() { FILE *fp = fopen("data.txt", "r"); Polygon *L = (Polygon *)malloc(sizeof(Polygon)); L->next = NULL; Polygon *p = L; char s[50]; double x1, y1, x2, y2; fscanf(fp, "%s", s); while (strcmp(s, "END") != 0) { Polygon *q = (Polygon *)malloc(sizeof(Polygon)); q->next = NULL; strcpy(q->name, s); if (!strcmp(s, "LINE")) { // ������������������ fscanf(fp, "%lf%lf%lf%lf", &x1, &y1, &x2, &y2); } else if (!strcmp(s, "RECT")) { // ��������������������� fscanf(fp, "%lf%lf%lf%lf", &x1, &y1, &x2, &y2); } else if (!strcmp(s, "CIRCLE")) { // ��������������� fscanf(fp, "%lf%lf%lf", &x1, &y1, &Radius); } // ������������ // ��������������� `&` ������������������ printf("%.2f %.2f %.2f %.2f\n", x1, y1, x2, y2); printf("\n\n"); fgetc(fp); // ������������������ p->next = q; p = q; // ��������������������� fscanf(fp, "%s", s); } fclose(fp);
������������������
1. ���������������
stdio.h
���������������������������stdlib.h
���������������������string.h
������������������
2. ������������������
Point
���������������������������Polygon
������������������������������������������������������������������
3. ���������������
发表评论
最新留言
第一次来,支持一个
[***.219.124.196]2025年04月09日 08时47分41秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
idea右边maven窗口
2021-05-10
CentOS7使用keepalive实现nginx的高可用
2021-05-10
Centos7.4下mysql5.6开启ssl
2021-05-10
srvctl命令详解
2021-05-10
linux centos6.4 磁盘分区、格式化、挂载
2021-05-10
oracle查看字符集后修改oracle服务端和客户端字符集的步骤
2021-05-10
Oracle闪回查询总结
2021-05-10
NAT端口复用型
2021-05-10
android中自定义标题栏左边距问题
2021-05-10
c学习14-bool、float、指针变量与“零值”比较的if语句
2021-05-10
c学习-28
2021-05-10
Linux环境编程--03 文件IO
2021-05-10
使用C语言获取文件夹地址的方法收藏
2021-05-10
线程的实现方式(java)
2021-05-10
KNN算法
2021-05-10
微盟实习
2021-05-10
HDU——3374 String Problem (最大最小表示法+循环节+kmp)
2021-05-10