Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct List{
  6.     int f;
  7.     struct List * next;
  8. };
  9.  
  10. List* create(){
  11.     List *pom=new List;
  12.     pom->next=NULL;
  13.     return pom;
  14. }
  15.  
  16. List* back(List *Lista){
  17.     while(Lista->next!= NULL)
  18.     Lista = Lista->next;
  19.     return Lista;
  20.  
  21. }
  22.  
  23. void push_back(List *Lista, int f){
  24.     List *pom=back(Lista);
  25.     List *nowy=new List;
  26.     nowy->f=f;
  27.     nowy->next=NULL;
  28.     pom->next=nowy;
  29. }
  30.  
  31. void wyswietl(List **t, int ilosc_el)// wyświeltam zapisane informacje
  32. {
  33.    for(int i = 0; i < 10; i++)// ilość elementów w "głównej" tablicy
  34.    {
  35.       cout << "Tablica o indeksie: " << i << " ";
  36.       List *pom = t[i];
  37.       while(pom)// przeszukuje liste  dla kazdego elementu "głownej" tablicy
  38.       {
  39.          cout << pom->f<< " ";
  40.          pom = pom->next;
  41.       }
  42.       std::cout << std::endl;
  43.    }
  44. }
  45.  
  46.  
  47.  
  48. int main(){
  49.     int f,m,o;
  50.     int n;
  51.     cin>>n;
  52.     const int ilosc_el=10;
  53.     List **tablica = new List *[ilosc_el];
  54.     for(int i = 0; i < ilosc_el; i++)
  55.         tablica[i] = 0;
  56.     for(int i = 0; i < n; i++){
  57.             cin >> o >> m >> f;
  58.             if (o==0)
  59.             {  
  60.                    
  61.             }
  62.             if (o==1)
  63.             {
  64.                
  65.             }
  66.             if (o==2)
  67.             {
  68.                
  69.             }
  70.            
  71.     }
  72.     wyswietl(tablica,ilosc_el);
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement