Results 1 to 8 of 8

Thread: C++ :

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Nov:2009
    Location:
    Posts: 83

    C++ :

    ,
    , . , . , , . :
    - , .

    , "" , , , :

    Code:
    #include <iostream>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <new>
    using namespace std;
    struct spis{
           char info[11];
           spis *next,*prev;
           };
    typedef spis* Point;
    
    Point Head1;
    Point Head2;
    Point Head3;
    Point Head4;
    
    Point Search(char X[11],Point P){
        while((P!=NULL) && (strcmp(P->info,X)!=0)) P=P->next;
         return P;
            
    }
    
    
    void Create2(char K[11], Point &Head){
         Point Last, P;
         P = new spis;
         strcpy(P->info,K);
         P->next=NULL;
         if (Head == NULL) {Head = P; P->prev=NULL;}
            else	{P->prev=Last;
                     Last->next=P;}
         Last = P;	
    }	
    void sech(Point P){
         while (P!=NULL){
               Point PointK=Search(P->info, Head2);
               if (PointK!=NULL) Create2(P->info,Head3);
               P=P->next;
               }
    }        
    
    
                      
    int main(){
        Point Head1=NULL;
        Point Head2=NULL;
        Point Head3=NULL;
        Create(Head1);
        Create(Head2);
        sech(Head1);
        cout<<"SECHENIE: \n";
        traverse(Head3);
        
        getchar();
        system("pause");
        return 0;
    }
    traverse( ),Create( ), , , .

    :
    1. Search 1 (Head1), (Head2), , .
    2. sech, SearchK, Search, NULL, Create2, (Head1) , (Head3), .

    , (Create), (traverse). , . .., , , . .
    Last edited by JuneK; 22nd November 2012 at 11:17.

  2. #2
    Registered User
    Join Date: Nov:2009
    Location:
    Posts: 83
    , / .... , , , . + , ... .
    :
    - , 2 , , .

    :
    1. , .
    2. , .

    , :
    Code:
    struct Item { char vyz[5];
                  Item *L, *R;};
    struct spis {char info[10];
                spis *next,*prev;};
         
    typedef Item* Point;
    typedef spis* Point2;
    Point2 Head;
    Point root;
    
    void create(char x[5], Point &p){            //  
    
    if (p==NULL) {strcpy(p->vyz,x);
                       p->L=p->R=NULL;} 		
       else if (strcmp(p->vyz,x)<0) return create(x,p->L);
    	     else if (strcmp(p->vyz,x)>=0) return create (x,p->R);
    }
    
    void dyrvo(Point2 P){             //       ,  .    
         while (P!=NULL){
               char nov[3];
               char star[11];
               strcpy(star,P->info);
               nov[0]=star[0];
               nov[1]=star[strlen(star)-1];
               nov[2]='\0';
               create(nov,root);
               P=P->next;};
    }
    
    void print(Point p){
         if (p!=NULL){
            cout<<p->vyz<<endl;
            print(p->L);
            print(p->R);
            }
    }
    
    int main(){
        Point root=NULL;
        Point2 Head=NULL;
        
       syzdavane(Head); //  
       dyrvo(Head); 
       print(root); // 
        
        getchar();
        system("pause");
        return 0;
    }
    , , , , . , , . , , , . , .
    "", . , , .

    .. , , , , . .

  3. #3
    Deleted User 4eRNoBiL's Avatar
    Join Date: Oct:2005
    Location:
    Posts: 739
    - sech() Head2 Head3? , , , main(), , .
    , , ? Head3. - , . return, .
    Fujistu Lifebook E756 | Core i7-6500U / 400MHz-3.1GHz | 8 GB DDR4-2133 | Samsung PM871 / 256 GB SSD | 15" 1920x1080 | Manjaro Linux + kernel 4.19

  4. #4
    Registered User
    Join Date: Nov:2009
    Location:
    Posts: 83
    , .
    , , . "", , .
    .

  5. #5
    Deleted User 4eRNoBiL's Avatar
    Join Date: Oct:2005
    Location:
    Posts: 739
    . traverse(Head3); Head3, main(), . sech() . main(), .

    sech():
    Code:
    void sech(Point Point1, Point Point2, Point *result){
         while (Point1 != NULL){
               Point PointK = Search(Point1->info, Point2);
               if (PointK != NULL) Create2(Point1->info, *result);
               Point1 = Point1->next;
         }
    }
    sech() :
    Code:
    int main(){
       //   ...
    
       sech(Head1, Head2, &Head3);
    }
    -, .
    Head1 Head4 main(), , .


    : Create2(), - Append() - ѝ ?
    Fujistu Lifebook E756 | Core i7-6500U / 400MHz-3.1GHz | 8 GB DDR4-2133 | Samsung PM871 / 256 GB SSD | 15" 1920x1080 | Manjaro Linux + kernel 4.19

  6. #6
    Registered User
    Join Date: Nov:2009
    Location:
    Posts: 83
    :
    1. sech , .
    2. Create2, , , Create2, .
    , .

    , :

    1 --- 1 ; 2 ; 3 ; 4; // ,
    2 --- 1 ; 2 ; 5; 3; // ,
    :
    --- 1 ; 2 ;
    --- 1;2;3;

    1 --- 3; 2 ; 1 ; // ,
    2 --- 1 ; 2 ; 3; // ,
    :
    --- 1 ;
    --- 1;2;3;

    1 --- 1; 2 ;// ,
    2 --- 1 ; 2 ; 3; // ,
    :
    --- 1 ; 2;
    .

    1 --- 2; 3 ; 1 ; // ,
    2 --- 1 ; 2 ; 3; // ,
    :
    --- 1 ;
    --- 1; 2; 3;



    :
    Code:
    Point Search(char X[11],Point &P){
        while((P!=NULL) && (strcmp(P->info,X)!=0)) P=P->next;
         return P;
            
    }
    
    void poziciq(char S[10], Point Head){
         Point P,Pprev,Q;
         P=Head->next;
         Pprev=Head;
         while (P && strcmp(P->info,S)<0){
               Pprev=P;
               P=P->next;};
         Q=new spis;
         strcpy(Q->info,S);
         Q->next=P;
         Pprev->next=Q;
    }  
    	
    void sech(Point P, Point Q, Point &Head){
         Point PointX;
         while (P!=NULL){
               PointX=Search(P->info,Q);
               if (PointX!=NULL) poziciq(P->info,Head);
               P=P->next;
               }
    }   
    
    int main(){
     //........
    
    sech(Head2,Head1,Head3);
    
    }
    , "&" P, Search:
    Code:
    Point Search(char X[11],Point P){
        while((P!=NULL) && (strcmp(P->info,X)!=0)) P=P->next;
         return P;
    }
    . . 2- .
    Last edited by JuneK; 22nd November 2012 at 13:28.

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 |