#include <iostream> using namespace std; struct Stu{ int score; Stu *prev; Stu *next; }; Stu *head = (Stu*)malloc(sizeof(Stu)), *t, *INDEX; int main(){ int n, score, s = 0; cin >> n; INDEX = head; while(n--){ cin >> score; t = (Stu*)malloc(sizeof(Stu)); t->next = nullptr; t->score = score; INDEX->next = t; INDEX = t; } INDEX = head->next; while(INDEX != nullptr){ s += INDEX->score; INDEX = INDEX->next; } cout << s; return 0; }
有话要说...