c - 如何从链表中分配值
问题描述
我正在为我的这个愚蠢的任务添加下一点,现在我正在修改我的旧代码,因为我正在实现这些“链接列表”的东西,但我不知道你是如何从中提取数据的?
所以,软件需要为你在列表中的任何行星提取变量,并将数字分配给变量,如果这有意义的话?
typedef struct Planet
{
char Planet_Name[30];
double Fuel;
double Velocity;
double Height;
double Gravity;
int Maximum_Thrust;
double Difficulty;
}Planet_t;
typedef struct PlanetNode
{
Planet_t* planet_Name;
struct PlanetNode* next;
}PlanetNode_t;
typedef struct PlanetList
{
PlanetNode_t* head;
int count;
}PlanetList_t;
(主要)
PlanetList_t* SolarSystem = calloc(1, sizeof(PlanetList_t));
printf("The Planets are (with their corresponding difficulty level)
Pluto[0], Moon[1], Mercury[2], Mars[3].....
double height = SolarSystem->head->Height;
double velocity = SolarSystem[PlanetNum]->Velocity;
double fuel = SolarSystem[PlanetNum]->Fuel;
double gravity = SolarSystem[PlanetNum]->Gravity;
double fuelBurn;
double difficulty = SolarSystem[PlanetNum]->Difficulty;
所以基本上,我需要弄清楚最后一点。程序的每次迭代都会改变选定的行星(线性穿过行星),因此每次都需要更新变量。
解决方案
推荐阅读
- javascript - 如何从数据表中获取单元格值?单元格值
- sql - 根据多列的条件查找不同的 ID [ANSI SQL]
- node.js - 将 mongo 服务器版本升级到 3.6 后出现各种 MongoDB 错误
- java - 如何了解 ide 中任何 java 注释的功能
- python - 如何在 Python 的一个程序中导入/使用两个不同版本的库(pytorch)?
- azure - 如何在 Azure devops 管道池中请求多个代理机器?
- python - django管理面板中不同用户的自定义用户查看/编辑权限
- javascript - View 不会更新,但 URL 在 React Router V6 中会更新
- c# - 使用 HttpClientHandler 创建 Httpclient 扩展
- python - 预测 X_test 集的前两个样本的房价并打印出来。(提示:使用 predict() 函数)