Results 1 to 9 of 9

Thread: (, )

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Sep:2008
    Location: /
    Posts: 42

    (, )

    . .. . - . ( , ) ? :
    Code:
    #include <iostream>
    using namespace std;
    struct zapis {
           int pole;
           zapis *next;};
    typedef zapis* po;
    po first=NULL,last=NULL,p,pprev;
    //LIFO
    void create(po &first){
         po p;char c;
         cout<<"Nov element?";
         cin>>c;
                while (c=='Y' || c=='y') {
                      p=new zapis; 
                      cout<<"Chislo"; 
                      cin>>p->pole; 
                      p->next=first; 
                      first=p; 
                      cout<<"Nov element"; 
                      cin>>c;
                       }
    }                
    void print(po p){
         while (p) { cout<<p->pole<<endl<<endl; p=p->next;} 
         system("PAUSE");
    }
    int iztrivane(po p){
    int chislo;
    cout<<"Chislo za iztrivane";
    cin>>chislo;
    while (p) {
               if(chislo==p->pole) {
                                        pprev->next=p->next;
                                        if(p==last) last=pprev;
                                        if(p==first) first=pprev->next;
                                        delete p;
                                        break;
                                        }
               pprev=p;
               p=p->next;}
    }
    
    int main(){
        create(first);
        iztrivane(first);
        print(first);
    }
    .. ( C), ?
    .

  2. #2

  3. #3
    Registered User
    Join Date: Sep:2008
    Location: /
    Posts: 42
    "=++", .

  4. #4
    Eclipse Plugin Developer aphex's Avatar
    Join Date: Mar:2003
    Location: Karlsruhe
    Posts: 546
    . , :

    : LILO(Last In, Last Out) .. , . stack() pop(). , .

    : FIFO(First In, First Out) .. , .

    : .

    , , , . , -1 +1(p-1-->p-->p+1). -1 +1 . .

    .
    We are drowning in information, but starving for knowledge and time!

  5. #5
    Registered User tedych's Avatar
    Join Date: Nov:2003
    Location:
    Posts: 17,654
    ": LILO(Last In, Last Out)"
    - - LIFO (last in first out)

    " stack() pop()"
    - - push() pop()

    " , -1 +1"
    - ( )? p+1, , p-1 p - , null.

    " ."
    - pop(), .

    , , , ? , pop() , , ..

  6. #6
    Registered User
    Join Date: Sep:2008
    Location: /
    Posts: 42
    , :
    Code:
    P->next = Head;
    Head = P;
    ( ?( )). ( , - , ) , -- , .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |