Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication2.cpp : Defines the entry point for the console application.
- //zadanie
- /*
- struktura zapisująca w każdej osobie imie i wskaźnik do następnej
- */
- #include "stdafx.h"
- #include <stdio.h>
- #include <conio.h>
- #include <time.h>
- #include <iostream>
- #include <string.h>
- //int a;
- using namespace std;
- int wybor;
- bool gra = true;
- int kolej = 0;
- int ilosc = 0;
- struct osoba
- {
- char name[20];
- struct osoba *next = NULL;
- };
- struct osoba *first = NULL;
- struct osoba *current = NULL;
- struct osoba *temp = NULL;
- int main()
- {
- do {
- cout << "1.dodaj " << endl;
- cout << "2.sprawdz" << endl;
- cout << "3.usun" << endl;
- cin >> wybor;
- system("cls");
- switch (wybor)
- case 1:
- {
- if (kolej == 0)
- {
- kolej++;
- first = new struct osoba;
- current = first;
- cin >> first->name;
- current->next = temp;
- cout << "dodales " << first->name << endl;
- ilosc++;
- break;
- }
- else;
- temp = new struct osoba;
- cin >> temp->name;
- current = temp;
- cout << "dodales " << temp->name << endl;
- current->next = temp;
- ilosc++;
- }
- if (wybor == 2) {
- current = first;
- cout << first->name << endl;
- temp = temp->next;
- //current = temp;
- for ( int i=2; i <ilosc; i++)
- {
- cout << current->name << endl;
- temp = temp->next;
- // current = temp;
- cout << temp->name << endl;
- temp = temp->next;
- }
- }
- } while (first != NULL);
- //tworze pierwsza osob
- /*
- first = new struct osoba;
- current = first;
- //tworze druga osoba
- temp = new struct osoba;
- current->next = temp;
- current = temp;
- //tworze trzecia osoba
- temp = new struct osoba;
- current->next = temp;
- current = temp;
- temp = first;
- while (temp != NULL)
- {
- cout << temp->name << endl;
- temp = temp->next;
- }
- //usuwanie
- int u = 3;
- temp = first;
- for (int i = 0; i < u - 2; i++) {
- temp = temp->next;
- }
- /* osoba *current = Lista;
- Lista = new osoba;
- cout << "podaj imie" << endl;
- cin >> a;
- Lista -> imie = a;
- cout << imie;
- current = Lista;
- current->next = new osoba;
- current = current->next;
- current = Lista;
- */
- getchar();
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement