#include #include #include #include #include #include struct komanda {char name[30]; char fio[30]; int nomer; int vozr; int rost; int ves;}; struct sport {char strana[30]; struct komanda komand;}; struct sport igrok; char c1[30],c2[30],c3[100]; int t1; fstream fil; void vvod(int m) { cout<<"\nvvedite dannue o "<<(m+1)<<" igroke:\n\n"; cout<<"strana: "; gets(c1); strcpy(igrok.strana,c1); cout<<"komanda: "; gets(c2); strcpy(igrok.komand.name,c2); cout<<"fio: "; gets(c3); strcpy(igrok.komand.fio,c3); cout<<"nomer: "; cin>>igrok.komand.nomer; cout<<"vozrast: "; cin>>igrok.komand.vozr; cout<<"rost: "; cin>>igrok.komand.rost; cout<<"ves: "; cin>>igrok.komand.ves; // ZAPIS v file polei 1 structuri fil<>key; if (key=='1') {clrscr(); m=0; //m-kol-vo zapisei //sozdanie novogo faila s rezimami dla dobavlenia fil.open("igro.dat",ios::trunc|ios::app); if (!fil) {cout<<"file not open"; return 1;} //vvod dannix (1 structuri) i zapis ee v file vvod(m); fil.close(); } if (key=='2') { clrscr(); cout<<"------------------------------------------------------------------------------\n"; printf("|%11s | %11s | %11s | %7s | %7s | %5s | %5s | \n", "strana","komanda","fio","nomer","vozrast","rost","ves"); cout<<"------------------------------------------------------------------------------\n"; //otkritie file dla chtenia fil.open("igro.dat",ios::out|ios::in); //po kol-vy zapisei proshitat file for(i=0;i<=m;i++) { //opredelenie tekushei posizii v file z=fil.tellp(); //perexod na tekushuu posiziu fil.seekp(z); //viravnivanie cout<<"|"; cout.setf(ios::right); // SHTENIE iz file polei 1 structuri fil>>igrok.strana; cout.width(11); cout<>igrok.komand.name; cout.width(12); cout<>igrok.komand.fio; cout.width(12); cout<>igrok.komand.nomer; cout.width(8); cout<>igrok.komand.vozr; cout.width(8); cout<>igrok.komand.rost; cout.width(6); cout<>igrok.komand.ves; cout.width(6); cout<>igrok.strana>>igrok.komand.name>>igrok.komand.fio>>igrok.komand.nomer>>igrok.komand.vozr>>igrok.komand.rost>>igrok.komand.ves; //sravnenie prochitannoi zapisi s vvedennoi if ((strcmp(igrok.komand.name,k)==0)&&(strcmp(igrok.strana,s)==0))//esli oni ravni { d++; pos[j]=z; vo[j]+=igrok.komand.vozr; ro[j]+=igrok.komand.rost; ve[j]+=igrok.komand.ves; } } cout<<"v komande "<vo[x]) {min1=vo[x]; r1=x;} if (maxve[x]) {min2=ve[x]; r3=x;}} //otkritie file dla shtenia/zapisi fil.open("igro.dat",ios::out|ios::in); //ustanovka ukazatela v file na posiziu fil.seekp(pos[r1]); // SHTENIE iz file polei 1 structuri fil>>igrok.strana>>igrok.komand.name; cout<<"samaya molodaya komanda "<>igrok.strana>>igrok.komand.name; cout<<"samaya roslaya komanda "<>igrok.strana>>igrok.komand.name; cout<<"samaya legkaya komanda "<