1234567891011121314151617181920212223242526272829303132333435363738394041424344
#include <iostream> #include <cstdlib> #include <ctime> #include <stddef.h> using namespace std; int main() { struct node{ int m; int l; node* p; }; srand(time(0)); node* n; node* t; node* h; n = new node; h = n; n->l = rand() % 10; n->m = 1; t = n; for (int i = 2; i < 100; ++i) { n = new node; t->p = n; t = n; n->l = rand() % 10; n->m = i; }; n->p = nullptr; t = h; while (t!= nullptr) { cout << t->m << "--" << t->l << '\t'; t = t->p; };