.


:




:

































 

 

 

 


2.

: .

2 1,

1) ( );

2) ) ) , , ( );

3) , .

:

:

3 .

: ) ;

) , .

:

// :

#include<stdio.h>

#include<stdlib.h>

#include<conio.h>

#include<string.h>

#include<iostream.h>

#include<io.h>

struct Zap { char Fam[10]; //

int Bal[3]; //

float SRED; }; //

struct Rec { char Naz[15]; //

float PR[3];}; // %-

//****************************

Class PRED{//

friend class STUD;

Rec* P;

int N;

public:

void Input(); //

void Print(); //

PRED(int k){N=k; P=new Rec[k];}

~PRED(){delete []P;}

};

// PRED:

void PRED::Input(){// :

for(int i=0;i<N;i++){

cout<<"\n Input nazv. predmeta: "<<i+1<<"). ";cin>>P[i].Naz;

for(int j=0;j<3;j++)P[i].PR[j]=0;

}}

/ // :

void PRED::Print() { FILE *f=stdout; int k;

do{ fprintf(f,"\n---------------------------------------------------");

fprintf(f,"\n N Nazvanie SR_Bal Proc_5 Proc_2 ");

fprintf(f,"\n---------------------------------------------------");

for(int i=0;i<N;i++){

fprintf(f,"\n%4d). %15.14s",i+1,P[i].Naz);

for(int j=0;j<3;j++)fprintf(f," %8.2f",P[i].PR[j]);

}

fprintf(f,"\n---------------------------------------------------");

k=0;

if(f==stdout){cout<<"\n Save in file Predmet.txt? (1-Yes, 0-No): ";

cin>>k;if(k)f=fopen("Predmet.txt","wt");}

else fclose(f);

}while(k); }

//************************************

Class STUD{//

Zap* Mas;

int kol; //

public:

void Input(); //

void Input_con(int n); //

void Input_RND(int n); //

void Input_FL(); //

void Input_bin(FILE*); //

void Action(); // )

void Print_SR(); // .

void Print_table(FILE*); //

void Write_bin(FILE*); //

void Print_Sort(); //

int Save(); //

void Sort_Pole(int); //

void Punkt_B(PRED&); // )

STUD(){kol=0;} //

~STUD(){delete []Mas;} //

};

// STUD:

 

void STUD::Input(){ int i,N;

cout<<"\n Input data from:";

cout<<"\n 1- Consol, 2- RND, 3- File (0- Exit): -> "; cin>>i;

if(!i)exit(0);

if(i<3){cout<<"\n Input kol-vo zapisei: "; cin>>N;}

switch(i){

case 1:Input_con(N);break;

case 2:Input_RND(N);break;

case 3:Input_FL();

} }

void STUD::Input_FL(){ FILE* ft; int L; char NF[15];

//------------------------------------------

do{cout<<"\n Input File Name bin-file: ";cin>>NF;

ft=fopen(NF,"rb");

if(!ft){cout<<"\n File -> no exist!";break;}

Input_bin(ft); fclose(ft);L=0;

}while(L); }

void STUD::Input_bin(FILE* f) { Zap z;

if(kol)delete []Mas;

int i=fileno(f);

long L=filelength(i);

kol=L/sizeof(Zap);

cout<<"\n Kol-vo zapisei="<<kol;

Mas=new Zap[kol];

for(i=0;i<kol;i++)fread(Mas+i,sizeof(Zap),1,f);

cout<<"\n Press any key...";getch(); }

void STUD::Input_con(int n){ Zap z;

if(n>kol){ if(kol) delete []Mas; kol=n; Mas=new Zap[n]; }

for(int i=0;i<n;i++){

printf("\n %d). Input FAM: ",i+1); cin>>z.Fam;

for(int j=0;j<3;j++){

printf(" Input BAL %d: ",j+1); cin>>z.Bal[j];

}

z.SRED=0; Mas[i]=z; } }

void STUD::Input_RND(int n){ Zap z; int i,j;

char st[]="QWERTYUIOPASDFGHJKLZXCVBNM";

int k,L=strlen(st);

if(n>kol){ if(kol) delete []Mas; kol=n; Mas=new Zap[n]; }

randomize();

for(i=0;i<n;i++){ k=random(7);

for(j=0;j<2+k;j++) z.Fam[j]=st[random(L)];

z.Fam[j]='\0';

for(j=0;j<3;j++)z.Bal[j]=1+random(5);

z.SRED=0; Mas[i]=z; } }



<== | ==>
|
:


: 2017-03-18; !; : 287 |


:

:

- , .
==> ...

1945 - | 1742 -


© 2015-2024 lektsii.org - -

: 0.019 .