,   CyberForum.ru

, : - C++

 
filimoncc
1 / 1 / 1
: 02.12.2013
: 101
04.06.2014, 21:16     , : #1
,
: , , ,
, . ,
, .

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
#include <iostream>
#include <fstream>
#include <iomanip> //äëÿ ì**èïóëÿòîð* setw, êîòîðûé ç*ä*åò øèðè*ó îòîáð*æ*åìîãî ïîëÿ
using namespace std;
 
//îòêðûâ*åì ãëîá*ëü*ûå ô*éëîâûå  ïîòîêè 
ifstream  in("input.txt"); 
ofstream  out("output.txt");
//îïèñ**èå ñòðóêòóðû 
struct sotr 
{
int salary,year,experience; //ç/ï, ãîä ïðè*ÿòèÿ ** ð*áîòó, ñò*æ
char FIO[50], post[50];//ÔÈÎ, äîëæ*îñòü
void show(); //÷ëå*-ôó*êöèÿ äëÿ âûâîä* è*ôîðì*öèè ** ýêð** 
void print();  //÷ëå*-ôó*êöèÿ äëÿ âûâîä* è*ôîðì*öèè â ô*éë
};
void sotr::show()
{
cout <<" "<<FIO <<" "<< year <<" "<<post <<" "<< salary<<" "<<experience<<"\n"<<endl; 
}
void sotr::print()
{
cout <<" "<<FIO <<" "<< year <<" "<<post <<" "<< salary<<" "<<experience<<"\n"<<endl; 
}
int main()
 
{
    setlocale ( LC_ALL, "rus" );
sotr sotrudnik[25]; //îïèñûâ*åì ì*ññèâ ñòðóêòóð, ãäå ê*æäûé ýëåìå*ò èìååò òèï sotr
int god; 
int i,j,n=0;
if(!in) cout<<"Oøèáê* ïðè îòêðûòèè ô*éë* input.txt\n"; 
else 
{
while(in.peek()!=EOF) //÷òå*èå ä***ûõ èç ô*éë* 
{
in >>sotrudnik[n].FIO; 
in >>sotrudnik[n].year; 
in >>sotrudnik[n].post; 
in >>sotrudnik[n].salary;
in >>sotrudnik[n].experience;
sotrudnik[n].show(); //âûâîä ïðî÷òå**ûõ ä***ûõ ** ýêð** ÷åðåç ÷ëå*-ôó*êöèþ 
n++;
 
}
cout<<n<<endl;
cout<<" Ââåäèòå òåêóùèé ãîä: "; 
 cin>>god ;
 cout<<"\n"<<" Âûïîë*èëè î÷èñòêó ñîòðóä*èêîâ!"<<endl;
 cout<<"\n";
if(!out) cout<<"Oøèáê* ïðè îòêðûòèè ô*éë* output.txt\n"; 
else 
{
j=0;
for(i=0;i<n && !j;i++)
//ïîèñê ñòðóêòóðû ïî ñîâï*äå*èþ ïîëÿ ãîä* äëÿ óä*ëå*èÿ 
if(sotrudnik[i].year==god)
{
//âûïîë*ÿåì ñäâèã â ì*ññèâå ** îä*ó ïîçèöèþ
for(j=i;j<n-1 ;j++)
 {sotrudnik[j]=sotrudnik[j+1];
 n--; //óìå*üø*åì êîëè÷åñòâî ñîòðóä*èêîâ, èçá*âèâøèñü îò *åóãîä*ûõ
}
}
//ç*ïèñûâ*åì ðåçóëüò*ò* â *îâûé ô*éë 
for(i=0;i<n;i++)
{
sotrudnik[i].print();//ââîä ä***ûõ ** ô*éë ÷åðåç ÷ëå*-ôó*êöèþ ñòðóêòóðû
}
}
}
in.close();out.close();  
return 0;
}
, . , ?

1 16
Similar
41792 / 34177 / 6122
: 12.04.2006
: 57,940
04.06.2014, 21:16     , :
:

C++ (, ,, ) new
, C++
[] C++
, Common, , - 1 2 C++
C++ :
(, , , ,) C++
T1 C++
C++ :



:
.

: 14:55. GMT +3.
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
@Mail.ru