#include <stdio.h> #include <conio.h> #include <stdlib.h> //system(); 这个指令需要用到此头文件 #include <ctype.h> //toupper要用到 #include <malloc.h> //在内存管理时用到的头文件 void main() { int i; struct ListEntry { int number; struct ListEntry *next; } start, *node; start.next = NULL; // Empty list node = &start; // Point to the start of the list for (i = 1; i <= 10; i++) { node->next = (struct ListEntry *) malloc(sizeof(struct ListEntry)); node = node->next; node->number = i; node->next = NULL; } // Display the list node = start.next; while (node) { printf("%d ", node->number); node = node->next; } system("pause"); }
C经典之12-用链表存1-10的数字---ShinePans
时间: 2024-10-03 22:29:26