Results 1 to 17 of 17
Thread: C++
Hybrid View
-
13th June 2011 22:39 #1Registered User
Join Date: Jun:2011
Location: Bulgaria
Posts: 10
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; } }
-
13th June 2011 23:13 #2Registered User
Join Date: Jul:2005
Location: Varna
Posts: 51
. , -

:
1. , =.
2. . .
, .
-
14th June 2011 12:03 #3Registered User
Join Date: Jun:2011
Location: Bulgaria
Posts: 10
, , .
, . , . 25 , , .
-
14th June 2011 14:32 #4Registered User
Join Date: Jul:2005
Location: Varna
Posts: 51
.
main() .
p, . .
, .
-
14th June 2011 15:59 #5Registered User
Join Date: Jun:2011
Location: Bulgaria
Posts: 10
-
14th June 2011 16:48 #6
-
14th June 2011 20:45 #7Registered User
Join Date: Jun:2011
Location: Bulgaria
Posts: 10
, .
, , . . .
-
14th June 2011 21:05 #8Registered User
Join Date: Jul:2005
Location: Varna
Posts: 51
.
-
15th June 2011 18:03 #9Registered 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.
-
17th June 2011 12:31 #10Registered 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.
-
18th June 2011 10:58 #11Registered 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.
-
20th June 2011 20:10 #12Registered User
Join Date: Jun:2011
Location: Bulgaria
Posts: 10
?
-
21st June 2011 10:28 #13
:
vhod().Code:for(int i=0;i<n;i++) { p[i].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.
-
21st June 2011 12:11 #14Registered User
Join Date: Jun:2011
Location: Bulgaria
Posts: 10
, .Code:for(i=0;i<n;i++)p[i].izhod();
-
21st June 2011 12:15 #15
.. "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.
-
21st June 2011 16:05 #16Registered User
Join Date: Jun:2011
Location: Bulgaria
Posts: 10
-
23rd June 2011 15:30 #17Registered User
Join Date: Jul:2005
Location: Varna
Posts: 51
: char *ime,*kod,*talant;
: char ime[64], kod[64], talant[64];




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in