如何从链表中分配值

时间:2018-05-27 19:48:06

标签: 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;

所以基本上,我需要找出最后一点。程序的每次迭代都会改变选定的行星(线性穿过行星),因此每次都需要更新变量。

0 个答案:

没有答案