while(x!=9999){ s = (LNode *)malloc(sizeof(LNode)); s->data = x; r->next = s; r = s; cin>>x; }
时间: 2024-05-19 12:15:58 浏览: 60
C++单链表的创建方法
This code reads in a series of integers from the user until the value 9999 is entered. For each integer entered, a new node is created with the integer as its data value. The new node is then added to the end of a linked list. The variable "r" keeps track of the last node in the list and is updated each time a new node is added. The input value is stored in the variable "x" and is read in using the "cin" function from the C++ standard library.
阅读全文