Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- struct lista_elem{
- int value;
- lista_elem * next;
- };
- typedef struct lista_elem item;
- int _tmain(int argc, _TCHAR* argv[])
- {
- item *current, *head;
- head = NULL;
- for (int i = 0; i < 10;i++)
- {
- current = new lista_elem;
- current->value = i + 1;
- current->next = head;
- head = current;
- cout << i + 1 << "Head: " << head->value << endl;
- cout << i + 1 << "Head address: " << head << endl;
- cout << i + 1 << "Current: " << current->value << endl;
- cout << i + 1 << "Current address: " << current << endl << endl;
- }
- current = head;
- cout << "Current: " << current->value << endl;
- while (current)
- {
- switch (current->value)
- {
- case 2: break;
- case 5: current->value = 14; cout << current->value << " "; break;
- default: cout << current->value << " "; break;
- }
- current = current->next;
- }
- cout << endl << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement