最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

第一次大改之前的track.c

2023-09-10 13:16 作者:R_2147483647  | 我要投稿

#include #include #include #include typedef struct { ???float x, y; } Plot; FILE *file; char* color; const float r = 20; typedef struct TreeNode { ???char* name; ???int val; ???struct TreeNode** child; ???int childCount; } TreeNode; TreeNode* treeNodeInit(char* name, int val) { ???TreeNode* node = (TreeNode*)malloc(sizeof(TreeNode)); ???node->name = strdup(name); ???node->val = val; ???node->child = NULL; ???node->childCount = 0; ???return node; } void treeNodeAddChild(TreeNode* parent, TreeNode* child) { ???parent->childCount++; ???parent->child = (TreeNode**)realloc(parent->child, sizeof(TreeNode*) * parent->childCount); ???parent->child[parent->childCount - 1] = child; } void treeNodeFree(TreeNode* node) { ???if (node == NULL) { ??????return; ???} ???for (int i = 0; i < node->childCount; i++) { ??????treeNodeFree(node->child[i]); ???} ???free(node->child); ???free(node->name); ???free(node); } typedef struct { ???Plot** data; ???int* lengthArray; ???int size; ???int capacity; } PlotVector; PlotVector* plotVector; void plotVectorInit() { ???plotVector = (PlotVector*)malloc(sizeof(PlotVector)); ???plotVector->data = NULL; ???plotVector->lengthArray = NULL; ???plotVector->size = 0; ???plotVector->capacity = 0; } void plotVectorFree() { ???free(plotVector->lengthArray); ???free(plotVector->data); ???free(plotVector); } void plotVectorPushBack(Plot* plot, int sizeofPlotVector) { ???if (plotVector->size >= plotVector->capacity) { ??????int newCapacity = (plotVector->capacity == 0) ? 1 : plotVector->capacity * 2; ??????Plot** newData = (Plot**)realloc(plotVector->data, newCapacity * sizeofPlotVector); ??????int* newLengthArray = (int*)realloc(plotVector->lengthArray, newCapacity * sizeof(int)); ??????if (newData == NULL) { ?????????printf("Memory allocation failed.\n"); ?????????return; ??????} ??????plotVector->data = newData; ??????plotVector->capacity = newCapacity; ??????plotVector->lengthArray = newLengthArray; ???} ???plotVector->data[plotVector->size] = plot; ???plotVector->lengthArray[plotVector->size] = sizeofPlotVector; ???plotVector->size++; } void QBcurvePrint(int index) { ???if (index < 0 || index >= plotVector->size) { ??????printf("Invalid index.\n"); ??????return; ???} ???Plot* plots = plotVector->data[index]; ???int i = 0; ???float theta0, theta1 = atanf((plots[i + 1].y - plots[i].y) / (plots[i + 1].x - plots[i].x)); ???fprintf(file, "lengthArray[index] / sizeof(Plot) - 2) { ??????i++; ??????theta0 = theta1; ??????theta1 = atanf((plots[i + 1].y - plots[i].y) / (plots[i + 1].x - plots[i].x)); ??????fprintf(file, "L %f %f Q %f %f %f %f ", ?????????????plots[i].x + r * cosf(theta0 + M_PI), plots[i].y + r * sinf(theta0 + M_PI), ?????????????plots[i].x, plots[i].y, ?????????????plots[i].x + r * cosf(theta1), plots[i].y + r * sinf(theta1)); ???} ???fprintf(file, "L %f %f\" stroke=\"%s\" stroke-width=\"2\" fill=\"none\" />\n", plots[i + 1].x, plots[i + 1].y, color); } int main() { ???plotVectorInit(); ???file = fopen("output.svg", "w"); ???if (file == NULL) { ??????printf("Can not open SVG file.\n"); ??????return 1; ???} ???fprintf(file, "\n"); ???color = "black"; ???Plot a[] = {{0, 10}, {40, 10}, {70, 80}, {100, 100}, {140, 80}, {180, 20}}; ???Plot plot1[] = {{10, 20}, {20, 40}, {40, 20}}; ???Plot plot2[] = {200, 200}; ???plotVectorPushBack(plot1, sizeof(plot1)); ???plotVectorPushBack(plot2, sizeof(plot2)); ???plotVectorPushBack(a, sizeof(a)); ???QBcurvePrint(0); ???fprintf(file, "\n"); ???fclose(file); ???plotVectorFree(); ???return 0; }

第一次大改之前的track.c的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
南木林县| 吉林省| 吉隆县| 固阳县| 江安县| 稻城县| 淮北市| 喜德县| 上林县| 清远市| 舒城县| 曲松县| 淮北市| 宁乡县| 两当县| 精河县| 雅安市| 昆明市| 海门市| 万宁市| 沙雅县| 长海县| 乡城县| 桐柏县| 潮州市| 定边县| 永康市| 商都县| 教育| 全南县| 高淳县| 沾益县| 双牌县| 舒城县| 高雄县| 澄城县| 奈曼旗| 绵阳市| 富顺县| 阿克| 独山县|