Results 1 to 17 of 17

Thread: C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Jun:2011
    Location: Bulgaria
    Posts: 10

    Unhappy C++

    -. 12 C++ , , . , , , . . , C++ . , , , . , . , , , .

    .

    : http://imageshack.us/photo/my-images...611222126.jpg/

    ( 3- ):
    Code:
    #include <iostream.h>;
    #include <string.h>;
    class talanti
     {
      int n;
      char ime[46];
      int kod[11];
      char talant[21];
      int tochki;
      public:
      void vhod(char,int,char,int);
      void izhod(char);
     };
    
     void talanti::vhod(int, char,int,char,int)
      {
       int i;
       cout<<"Broi uchastnici: ";
       cin>>p.n;
       cout<<endl;
       for(i=0;i<p.n;i++)
        {
         cout<<"Trite imena: ";
         cin>>p[i].ime;
         cout<<"Kod: ";
         cin>>p[i].kod;
         cout<<"Talant: ";
         cin>>p[i].talant;
         cout<<"Tochki: ";
         cin>>p[i].tochki;
         cout<<endl;
        }
      }
     void talanti::izhod(char) //Tochka 2
      {
       int i,j;
       char swap;
       for(i=0;i<p.n;i++)
        {
         for (j=n-1;j>=i;j--)
          {
           if(strcmp(p[j-1].ime,p[j].ime)>0)
    	{
    	 swap=p[j-1].ime;
    	 p[j-1].ime=p[j].ime;
             p[j].ime=swap
    	}
          }
        }
       char * pos,str1,str2,str3,str4,str5,str6,str7,str8;
       int start_point=0;
       for(i=0;i<p.n;i++)
        {
         start_point=0;
         pos=strchr(p[i]," ");    
         strncpy(str1,p[i].ime,pos+1);
         start_point += str1_length;
         strncpy(str2,(p[i].ime+start_point,(p[i].ime.lenght()-pos));
         itoa(p[i].kod,str3, 10 );      
         strncpy(str4,str3,3);
         strncpy(str5,(str3+3),1);
         switch str5:
          {
           case "1":
    	str5="Sofiq"
           break;
    
           case "2":
    	str5="Plovdiv"
           break;
    
           case "3":
    	str5="Varna"
           break;
    
           case "4":
    	str5="Burgas"
           break;
    
           case "5":
    	str5="Ruse"
           break;
    
           case "6":
    	str5="Blagoevgrad"
           break;
          };
         strncpy(str6,(str3+4),2);
         strncpy(str7,(str3+6),2);
         strncpy(str8,(str3+8),2);
         cout<<str1<<"."<<str2<<", "<<str4<<", "<<str5<<", "<<talant<<", "<<tochki<<", "<<str6<<"."<<str7<<"."<<str8<<endl;
        }
      }

  2. #2
    Registered User
    Join Date: Jul:2005
    Location: Varna
    Posts: 51
    . , -

    :
    1. , =.
    2. . .

    , .

  3. #3
    Registered User
    Join Date: Jun:2011
    Location: Bulgaria
    Posts: 10
    , , .

    , . , . 25 , , .

  4. #4
    Registered User
    Join Date: Jul:2005
    Location: Varna
    Posts: 51
    .

    main() .

    p, . .
    , .

  5. #5
    Registered User
    Join Date: Jun:2011
    Location: Bulgaria
    Posts: 10
    Quote Originally Posted by martinmax33 View Post
    ( 3- ):
    , . . p , main ( ).

  6. #6
    Registered User
    Join Date: Jul:2005
    Location: Varna
    Posts: 51
    ++, .
    - , - .

    , .

  7. #7
    Registered User
    Join Date: Jun:2011
    Location: Bulgaria
    Posts: 10
    , .

    , , . . .

  8. #8
    Registered User
    Join Date: Jul:2005
    Location: Varna
    Posts: 51
    .


  9. #9
    Registered User
    Join Date: Jun:2011
    Location: Bulgaria
    Posts: 10
    . - . . , . , , . cannot convert char* to char, array .

    Code:
    #include <iostream.h>;
    #include <fstream.h>;
    #include <string.h>;
    #include <iomanip.h>;
    class tal
     {
      char *ime;
      char *kod;
      char *talant;
      int tochki;
      public:
      void vhod();
      void izhod();
     }p[500];
    int n;
    void tal::vhod()
     {
      for(int i=0;i<n;i++)
       {
        cout<<"Trite imena: ";
        cin.getline(p[i].ime,46);
        cout<<"Kod: ";
        cin.getline(p[i].kod,11);
        cout<<"Talant: ";
        cin.getline(p[i].talant,21);
        cout<<"Tochki: ";
        cin>>p[i].tochki;
        cout<<endl;
       };
     };
    void tal::izhod()
     {
      char *swap;
      for(int i=0;i<n;i++)
       {
        for (int j=n-1;j>=i;j--)
         {
          if(strcmp(p[j-1].ime,p[j].ime)>0)
           {
    	swap=p[j-1].ime;
            p[j-1].ime=p[j].ime;
            p[j].ime=swap;
           };
         };
       };
      char *pos,str1,str2,str3,str4,str5,str6,str7,str8;
      int spoint;
      size_t found;
      for(i=0;i<n;i++)
       {
        str1=p[i].ime;
        found=str1.find_first_of(" ");      
        strncpy(str2, str1,(found+1));
        /*
        strncpy(str3,str1,);
        itoa(p[i].kod,str3, 10 );      
        strncpy(str4,str3,3);
        strncpy(str5,(str3+3),1);
        switch str5:
         {
          case "1":
           str5="Sofiq"
          break;
    
          case "2":
           str5="Plovdiv"
          break;
    
          case "3":
           str5="Varna"
          break;
    
          case "4":
           str5="Burgas"
          break;
    
          case "5":
           str5="Ruse"
          break;
    
          case "6":
           str5="Blagoevgrad"
          break;
         };
        strncpy(str6,(str3+4),2);
        strncpy(str7,(str3+6),2);
        strncpy(str8,(str3+8),2);
        cout<<str1<<"."<<str2<<", "<<str4<<", "<<str5<<", "<<talant<<", "<<tochki<<", "<<str6<<"."<<str7<<"."<<str8<<endl;
        */
       }
     }
    int main()
     {
      cout<<"Broi uchastnici: ";
      cin>>n;
      cout<<endl;
      if(n<1 || n>500)
       {
        cout<<"Greshen broi uchastnici!"<<endl;
        return 1;
       }
      *p;
      p=tal;
      p.vhod();
      p.izhod();
      return 0;
     }
    .. , .
    Last edited by martinmax33; 15th June 2011 at 18:33.

  10. #10
    Registered User
    Join Date: Jul:2005
    Location: Varna
    Posts: 51
    Code:
    #include <iostream.h>
    #include <fstream.h>
    #include <string.h>
    #include <iomanip.h>
    class tal
     {
      char *ime;
      char *kod;
      char *talant;
      int tochki;
      public:
      void vhod();
      void izhod();
     }p[500];
    int n;
    void tal::vhod()
     {
      for(int i=0;i<n;i++)
       {
        cout<<"Trite imena: ";
        cin.getline(p[i].ime,46);
        cout<<"Kod: ";
        cin.getline(p[i].kod,11);
        cout<<"Talant: ";
        cin.getline(p[i].talant,21);
        cout<<"Tochki: ";
        cin>>p[i].tochki;
        cout<<endl;
       };
     };
    void tal::izhod()
     {
      char *swap;
      for(int i=0;i<n;i++)
       {
        for (int j=n-1;j>=i;j--)
         {
          if(strcmp(p[j-1].ime,p[j].ime)>0)
           {
    	swap=p[j-1].ime;
            p[j-1].ime=p[j].ime;
            p[j].ime=swap;
           };
         };
       };
      char *pos, *str1, *str2, *str3, *str4, *str5, *str6, *str7, *str8;
      int spoint;
      size_t found;
      for(i=0;i<n;i++)
       {
        str1=p[i].ime;
        //found=str1.find_first_of(" ");      
        //strncpy(str2, str1,(found+1));
        /*
        strncpy(str3,str1,);
        itoa(p[i].kod,str3, 10 );      
        strncpy(str4,str3,3);
        strncpy(str5,(str3+3),1);
        switch str5:
         {
          case "1":
           str5="Sofiq"
          break;
    
          case "2":
           str5="Plovdiv"
          break;
    
          case "3":
           str5="Varna"
          break;
    
          case "4":
           str5="Burgas"
          break;
    
          case "5":
           str5="Ruse"
          break;
    
          case "6":
           str5="Blagoevgrad"
          break;
         };
        strncpy(str6,(str3+4),2);
        strncpy(str7,(str3+6),2);
        strncpy(str8,(str3+8),2);
        cout<<str1<<"."<<str2<<", "<<str4<<", "<<str5<<", "<<talant<<", "<<tochki<<", "<<str6<<"."<<str7<<"."<<str8<<endl;
        */
       }
     }
    int main()
     {
      cout<<"Broi uchastnici: ";
      cin>>n;
      cout<<endl;
      if(n<1 || n>500)
       {
        cout<<"Greshen broi uchastnici!"<<endl;
        return 1;
       }
    
      p[0].vhod();
      p[0].izhod();
      return 0;
    }
    .
    find_first_of strchr strstr.

    PP: . p .
    Last edited by FlyAway; 17th June 2011 at 12:46.

  11. #11
    Registered User
    Join Date: Jun:2011
    Location: Bulgaria
    Posts: 10
    !

    !
    , . strchr, , . , .

    ..
    , . ... .

    Code:
    #include <iostream.h>;
    #include <fstream.h>;
    #include <string.h>;
    #include <iomanip.h>;
    class tal
     {
      public:
      char *ime,*kod,*talant;
      int tochki;
      public:
      void vhod();
      void izhod();
     }p[500];
    int n;
    char *swap;
    void tal::vhod()
     {
      cout<<"Trite imena: ";
      cin.getline(ime,46);
      cout<<"Kod: ";
      cin.getline(kod,11);
      cout<<"Talant: ";
      cin.getline(talant,21);
      cout<<"Tochki: ";
      cin>>tochki;
      cout<<endl;
     };
    void tal::izhod()
     {
      char *str1,*str2,*str3,str4,*str5,*str6,*str7,*str8;
      int found=1;
      for(char *where=ime; *where!=' ';++where)found+=1;
      strncpy(str1,ime,found);
      str1 += '.\n';
      for(*where=ime[found]; *where!=' ';++where)found+=1;
      do
       {
        str2 +=ime[found];
        found+=1;
       }
      while(ime[found]!='\n');
      str2 +='\n';
      strncpy(str3,kod,3);
      str4=kod[3];
      switch(str4)
         {
          case 1:
           str5="Sofiq";
          break;
    
          case 2:
           str5="Plovdiv";
          break;
    
          case 3:
           str5="Varna";
          break;
    
          case 4:
           str5="Burgas";
          break;
    
          case 5:
           str5="Ruse";
          break;
    
          case 6:
           str5="Blagoevgrad";
          break;
         };
      strncpy(str6,(kod+4),2);
      strncpy(str7,(kod+6),2);
      strncpy(str8,(kod+8),2);
      cout<<str1<<str2<<", "<<str3<<", "<<str5<<", "<<talant<<", "<<tochki<<", "<<str6<<"."<<str7<<"."<<str8<<endl;
     }
    int main()
     {
      cout<<"Broi uchastnici: ";
      cin>>n;
      cout<<endl;
      if(n<1 || n>500)
       {
        cout<<"Greshen broi uchastnici!"<<endl;
        return 1;
       }
      for(int i=0;i<n;i++)
       { 
        p[i].vhod();
       }
      for(i=0;i<n;i++)
       {
        for (int j=n-1;j>=i;j--)
         {
          if(strcmp(p[j-1].ime,p[j].ime)>0)
           {
    	swap=p[j-1].ime;
            p[j-1].ime=p[j].ime;
            p[j].ime=swap;
           };
         };
       }
      for(i=0;i<n;i++)p[i].izhod();
      return 0;
     }
    Last edited by martinmax33; 18th June 2011 at 18:29.

  12. #12
    Registered User
    Join Date: Jun:2011
    Location: Bulgaria
    Posts: 10
    ?

  13. #13
    System.gc()'s Avatar
    Join Date: Apr:2007
    Location: back in time
    Posts: 1,075
    :
    Code:
      for(int i=0;i<n;i++)
      { 
        p[i].vhod();
      }
    vhod().
    UD3R|Q9550+1283|4x2 G.Skill@1066|MX500+1002FAEX+640AAKS+ST31 60|RX580-8GB|1841BLT|SS-760XP|Define7|z24i|Edifier S350DB
    geniusloci: ) ; ) ; ) ? nope|r.i.p.

  14. #14
    Registered User
    Join Date: Jun:2011
    Location: Bulgaria
    Posts: 10
    Code:
    for(i=0;i<n;i++)p[i].izhod();
    , .

  15. #15
    System.gc()'s Avatar
    Join Date: Apr:2007
    Location: back in time
    Posts: 1,075
    .. "Kod", "Talant", "Tochki" vhod?
    UD3R|Q9550+1283|4x2 G.Skill@1066|MX500+1002FAEX+640AAKS+ST31 60|RX580-8GB|1841BLT|SS-760XP|Define7|z24i|Edifier S350DB
    geniusloci: ) ; ) ; ) ? nope|r.i.p.

  16. #16
    Registered User
    Join Date: Jun:2011
    Location: Bulgaria
    Posts: 10

  17. #17
    Registered User
    Join Date: Jul:2005
    Location: Varna
    Posts: 51
    : char *ime,*kod,*talant;
    : char ime[64], kod[64], talant[64];

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 |