3.
: ϻ.
3 2,
- ) ) , ( ).
:
:
3 .
: ) ;
) , .
:
// :
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<iostream.h>
#include<io.h>
// ( STRING):
#include "My_str.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 Input_txt(FILE*); //
Zap Sozd_ZAP(char*); //
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 File: 1 - txt, 2 - bin, 0 - Exit: ";cin>>L;
switch(L){
case 1:ft=fopen(NF,"rt"); if(!ft){cout<<"\n File -> no exist!";break;}
Input_txt(ft);fclose(ft);L=0;break;
case 2: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(); }