У меня есть задание создать программу, которая получает 14 баллов и помещает их в двусвязный список, чтобы я мог отсортировать данные, но я заметил, что вы не можете вставить массив чисел в связанный список по сути
int scores[15]
в связанный список.
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<string.h>
#include<windows.h>
#include<conio.h>
struct mhs{
char name[30];
int scores[15];
int finalScore;
struct mhs *next, *prev;
};
void data(struct mhs **head, struct mhs **node, struct mhs **tail){
char nama[30];
int scores[15];
int finalScore;
int i, sum = 0;
system("cls");
printf("Name: ");
scanf("[^\n]", name);
fflush(stdin);
for(i = 0; i < 14 ; i++){
printf("Score %d: ", i+1);
scanf("%d", &scores[i]);
}
for(i = 13; i > 3; i--){
sum = sum + scores[i];
}
printf("Final Score: %d\n", sum / 10);
system("pause");
(*node) = (struct mhs*) malloc(sizeof(struct mhs));
strcpy((*node)->nama, nama);
(*node)->scores= scores; //here's where I insert the scores
(*node)->finalScore= finalScore;
if(*head == NULL){
*head = *node;
*tail = *node;
} else {
(*tail)->next = *node;
(*node)->prev = *tail;
*tail = *node;
}
}
void данные - это функция из int main (), поэтому структура использует указатель. Может кто-нибудь сказать мне, как добавить массив чисел в связанный список?