abdukodir

Untitled

Dec 17th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. #include<cstdio>
  2. #include<string>
  3. #include<vector>
  4. #include<set>
  5. #include<iostream>
  6. #include<fstream>
  7. #include<algorithm>
  8. using namespace std;
  9. #define sc scanf
  10. #define pr printf
  11. #define fr first
  12. #define se second
  13. #define pb push_back
  14. #define mp make_pair
  15. const int MN = 5010;
  16. const int MM = 5010;
  17. const int mod = 1000000007;
  18. int q, f;
  19. string p_naz, dt, s;
  20. struct fio{
  21. string f, i, o;
  22. bool operator<(fio x)const{
  23. if(f<x.f)return 1;
  24. if(f>x.f)return 0;
  25. if(i<x.i)return 1;
  26. if(i>x.i)return 0;
  27. if(o<x.o)return 1;
  28. return 0;
  29. }
  30. };
  31. struct data{
  32. fio A;
  33. string ph, bd, sb;
  34. bool operator<(data x)const{
  35. return A<x.A;
  36. }
  37. };
  38. struct data2{
  39. fio A;
  40. string ph, bd, sb;
  41. bool operator<(data2 x)const{
  42. return bd<x.bd;
  43. }
  44. };
  45. set<data>base;
  46. set<data>::iterator it;
  47. set<data2>po_bd;
  48. set<data2>::iterator it2;
  49. int main(){
  50. while(1){
  51. pr("Viberite nomer operacii\n");
  52. pr("0. Vyhod\n");
  53. pr("1. Dobavit studenta\n");
  54. pr("2. Sohranit vsego spisok v fayl\n");
  55. pr("3. Otkrit spisok iz faila\n");
  56. pr("4. Vyvodit dannie studenta po nomeru studbileta\n");
  57. pr("5. Vyvodit studentov otsartirovannuyu po date rojdeniya\n");
  58. cin>>q;
  59. if(q == 0){
  60. return 0;
  61. }
  62. if(q == 1){
  63. data n;
  64. data2 n2;
  65. cout<<"FIO cherez probel: ";
  66. cin>>n.A.f>>n.A.i>>n.A.o;
  67. n2.A.i = n.A.i;
  68. n2.A.f = n.A.f;
  69. n2.A.o = n.A.o;
  70. cout<<"Telefon: ";
  71. cin>>n.ph;
  72. n2.ph = n.ph;
  73. cout<<"Data rojdeniya v formate ggggmmdd: ";
  74. cin>>n.bd;
  75. n2.bd = n.bd;
  76. cout<<"nomer studbileta: ";
  77. cin>>n.sb;
  78. n2.sb = n.sb;
  79. base.insert(n);
  80. po_bd.insert(n2);
  81. }
  82. if(q == 2){
  83. ofstream fout("out.txt");
  84. for(it = base.begin(); it != base.end(); it++){
  85. fout<<it->A.f<<" "<<it->A.i<<" "<<it->A.o<<" "<<it->ph<<" "<<it->bd<<" "<<it->sb<<endl;
  86. }
  87. fout.close();
  88. }
  89. if(q == 3){
  90. ifstream fin("in.txt");
  91. while(1){
  92. data n;
  93. data2 n2;
  94. fin>>n.A.f>>n.A.i>>n.A.o>>n.ph>>n.bd>>n.bd>>n.sb;
  95. if(n.A.f.size() == 0){
  96. break;
  97. }
  98. n2.A.f = n.A.f;
  99. n2.A.i = n.A.i;
  100. n2.A.o = n.A.o;
  101. n2.ph = n.ph;
  102. n2.sb = n.sb;
  103. }
  104. fin.close();
  105. }
  106. if(q == 4){
  107. cout<<"Vvodite nomer studbileta: "<<endl;
  108. cin>>s;
  109. for(it = base.begin(); it != base.end(); it++){
  110. if(it->sb == s){
  111. break;
  112. }
  113. }
  114. if(it == base.end()){
  115. cout<<"Takoy student ne sushestvuet"<<endl;
  116. }
  117. else {
  118. cout<<it->A.i<<" "<<it->A.f<<" "<<it->A.o<<" "<<it->ph<<" "<<it->bd<<" "<<it->sb<<endl;
  119. }
  120. }
  121. if(q == 5){
  122. for(it2 = po_bd.begin(); it2 != po_bd.end(); it2++){
  123. cout<<it2->A.f<<" "<<it2->A.i<<" "<<it2->A.o<<" "<<it2->ph<<" "<<it2->bd<<" "<<it2->sb<<endl;
  124. }
  125. }
  126. }
  127. return 0;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment