,   CyberForum.ru

++


 
Uksus
13 / 13 / 4
: 27.09.2010
: 53
#1

. - C++

11.03.2012, 21:14. 225. 0
( )

( ). , , .

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#include <dir.h>//  mkdir( )
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <alloc.h>
#include <string.h>
#include <iostream.h>
 int ndig(char x)
{if('0'<=x&&x<='9')return 0;else return 1;}
//     
 struct stud
{char fio[122];int b[9],ns;// 
static int nc//   fio
,nd;// 
 void out(FILE*fo);stud(){fio[121]=0;}
stud(FILE*fi);
stud(stud&s){*this=s;}
}; //end of stud body
 int stud::nc=44;
 int stud::nd=5;
 stud::stud(FILE *fi)
{fscanf(fi,"%i ",&ns); fgets(fio,nc,fi);
for(int j=1;j<=nd;++j)fscanf(fi,"%i",&b[j]);}
 
 void stud::out(FILE*fo=stdout)
{fprintf(fo,"%3i ",ns);
fputs(fio,fo); for(int j=1;j<=nd;++j)
{if(b[j]>=0&&b[j]<6) fprintf(fo,"%3i",b[j]);
else fprintf(fo,"   ");}
fprintf(fo,"\n"); if ( fo==stdout) getch();
}//end of stud
 
//  
//(" "   )
 
 struct grup{ stud**st;//" "
FILE*fi;char title[3][122]//"" 
,sf[77];
 
int ms;// 
void nw();//  
void out(char*sf); void out(FILE*fo);
grup(grup&g);grup(int fms){ms=fms; nw();}
grup(char*sf); grup&operator=(const grup&g);
void deg();~grup(){deg();} grup(); };
//end of grup body
 
 grup::grup(){ms=0;st=0;fi=0;
for(int j=0;j<3;++j)memset(title[j],0,122);}
 
 void grup::nw()
{st=new stud*[ms+1];
if(!st){cout<<"\nst=0  grup::nw()\n";exit(1);}
for(int j=0;j<=ms;++j)
{st[j]=new stud;
if(!st){cout<<"\nst[j]=0\n";exit(1);}
}}
 grup::grup(char*fsf)
{strcpy(sf,fsf); char s[77]="\n"; int j;
fi=fopen(sf,"rt");
if(!fi)
{cout<<"\n0)fi=0,sf="<<sf;getch();exit(1);}
//ר    sf:
ms=0; while(!feof(fi)){fgets(s,77,fi);++ms;}
ms-=3; fclose(fi); fi=fopen(sf,"rt");
if(!fi){cout<<"\nfi\n";exit(1);}
for(j=0;j<3;++j) fgets((title[j]),77,fi);
 
// ""   sf
nw();for(j=1;j<=ms;++j){stud stj(fi);*st[j]=stj;}
fclose(fi);
}
 grup&grup::operator=(const grup&g)
{if(this==&g)return*this; int j; this->deg();
fi=g.fi; strcpy(sf,g.sf); ms=g.ms;
nw(); for(j=0;j<=ms;++j)*st[j]=*g.st[j];
for(j=0;j<3;++j)strcpy(title[j],g.title[j]);
return*this;
}
 grup::grup(grup&g)
{for(int j=0;j<3;++j)strcpy(title[j],g.title[j]);
ms=g.ms; strcpy(sf,g.sf);
nw(); for(j=0;j<=ms;++j)*st[j]=*g.st[j];
}
 void grup::deg()
{if(st) {for(int j=0;j<=ms;++j)
if(st[j]){delete st[j];st[j]=0;}delete[]st;st=0;}
}
 void grup::out(FILE*fo=stdout)
{if(fo==stdout)cout<<'\n'; int j=0;
for(;j<3;j++) fputs(title[j],fo);
 
for(j=1;j<=ms;j++) st[j]->out(fo);
}
 void grup::out(char*sf)
{FILE*fo=fopen(sf,"wt");
if(!fo){cout<<"\nfo=0\n";exit(1);}
out(fo); fclose(fo);
} //end of grup
 
//    (" ")
 struct potok{  grup**gr;//" "
char sf[77]; FILE*nf,*fo;int ng;
void nw();//  
potok(){gr=0;nf=fo=0;ng=0;sf[76]=0;}
potok(potok&p); potok(char*fsf,int ng);
void dep();~potok(){dep();}
potok&operator=(const potok&p);
void dout(char*dir,int nm);//   dir
void fout(char*f);//  ,   f
void out();
};//end of potok body
 
 void potok::nw(){ gr=new grup*[ng];
if(!gr){cout<<"\ngr=0\n";exit(1);}
for(int j=0;j<ng;++j) { gr[j]=new grup;
if(!gr[j]){cout<<"\ngr[j]=0\n";exit(1);} } }
 
 potok&potok::operator=(const potok&p)
{if(this==&p)return*this;   dep();
nf=p.nf;fo=p.fo; strcpy(sf,p.sf); ng=p.ng;
nw();  for(int j=0;j<ng;++j)*gr[j]=*p.gr[j];
return*this;
}
 potok::potok(potok&p)
{int j;ng=p.ng; nf=p.nf;fo=p.fo;
strcpy(sf,p.sf); nw();
for(j=0;j<ng;++j)*gr[j]=*p.gr[j];
}
 potok::potok(char*fsf,int fng)
{ ng=fng; char w[88];
gr=new grup*[ng];
if(!gr){cout<<"\ngr=0\n";exit(1);}
strcpy(sf,fsf); nf=fopen(sf,"rt");
if(!nf){cout<<"\n1) nf=0\n";exit(1);}
 for (int i=0;i<ng;++i)
{fscanf(nf,"%s",w);
gr[i]=new grup(w);//w-   i- 
if(!gr[i]){cout<<"\ngr[i]=0\n";exit(1);}
}fclose(nf);
}
 void potok::dep()
{if(gr){for(int i=0;i<ng;++i)
if(gr[i]){delete gr[i];gr[i]=0;}
delete[]gr;gr=0;}
}
 void potok::out()
{for(int i=0;i<ng;++i)gr[i]->out();
}
 void potok::fout(char*sn)
{nf=fopen(sn,"rt");
//sn   
//     
if(!nf)
 {cout<<"\n2) nf=0, sn= "<<sn<<'\n';exit(1);}
 for(int i=0;i<ng;++i)
{fscanf(nf,"%s",sf);//sf    
fo=fopen(sf,"wt");if(!fo){cout<<"\nfo\n";exit(1);}
gr[i]->out(fo); fclose(fo);
} fclose(nf);
}
 void potok::dout(char*dir,int nm)
//dir      
//nm -  
{int k=0,i=0,j=0;char t,sng[77]={0},**f;
f=new char*[ng];j=mkdir(dir);
//j=0,   dir    
/*
if(j){printf("\nPress blank for change files \
of folder %s, else exit.", dir);
if(getch()!=' ')exit(1);}
*/
for(i=0;i<ng;++i)
 {f[i]=new char[77];memset(f[i],0,77);
k=j=0;   while(t=gr[i]->title[1][j],t!='\n')
   {if(!ndig(t)){sng[k]=t;++k;}  ++j;
   }
sprintf(f[i],"%s\\m%iw%s.txt",dir,nm,sng);
FILE*w=fopen(f[i],"wt");
//f[i]      *gr[i]
gr[i]->out(w); fclose(w);
 }
for(i=0;i<ng;++i)delete[]f[i];
delete[]f;f=0; }
//end of potok
Similar
41792 / 34177 / 6122
: 12.04.2006
: 57,940
11.03.2012, 21:14     .
:

. C++
C++
C++
C++
C++
LU . (C++) C++
C++
vector<> C++
C++
C++
C++
C++ void c++



:
.

- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
@Mail.ru