500 likes | 524 Views
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; }. root s temp. NULL. ?. ?.
E N D
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp NULL ? ?
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp NULL abc ?
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp NULL abc ? ?
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp NULL abc abc ?
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp NULL abc abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp abc abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog ? abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog ? ? abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog dog ? abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog dog ? abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp hat ? dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp hat ? ? dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp hat hat ? dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next= root; root = temp; } ...... root s temp hat hat ? dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp hat hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root= temp; } ...... root s temp hat hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp hat hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz ? hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz ? ? hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz xyz ? hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz xyz ? hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next =root; root = temp; } ...... root s temp xyz xyz hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz xyz hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz xyz hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz ? xyz hat dog abc NULL
struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root xyz hat dog abc NULL
struct Link { string data; Link * next; Link(string a, Link * b) { data = a; next = b; } }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link(s, root); root = temp; } ...... root xyz hat dog abc NULL
struct Link { string data; Link * next; Link(string a, Link * b) { data = a; next = b; } }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; root = new Link(s, root); } ...... root xyz hat dog abc NULL
struct Link { string data; Link * next; Link(string a, Link * b) { data = a; next = b; } }; void main() { Link * root = NULL; while (true) { string s; cin >> s; if (cin.fail()) break; root = new Link(s, root); } ...... root xyz hat dog abc NULL
root cout << root->data; xyz hat dog abc NULL
root cout << root->data; cout << root->next->data; xyz hat dog abc NULL
root cout << root->data; cout << root->next->data; cout << root->next->next->data; xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root NULL while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root NULL while (root != NULL) { cout << root->data; root = root->next; } xyz hat dog abc NULL
root temp NULL Link * temp; temp = root; while (temp != NULL) { cout << temp->data; temp = temp->next; } xyz hat dog abc NULL