Anna3O0

Etapa a 3 a

Oct 13th, 2019
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3. #include <fstream>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. cout<<"Intoduceti : "<<endl;
  11. cout<<"0 pentru Adaugare "<<endl;
  12. cout<<"1 pentru Consultare "<<endl;
  13. cout<<"2 pentru Raport Simplificat "<<endl;
  14. cout<<"x pentru a Parasi "<<endl;
  15. char command ;
  16.  
  17. while(command!='x'){
  18. cin>>command;
  19.  
  20. if(command=='0'){
  21. string name1;
  22. ofstream nume("Catalog.txt",ofstream::app);
  23. cout << "Introduceti un nume cu sau fara cratima : ";
  24. int names=0;
  25. cin>>name1;
  26. names++;
  27. nume<<name1<<endl;
  28. nume.close();
  29.  
  30. int ziua, luna;
  31. float numar;
  32. ofstream date;
  33. string data;
  34. cout<<"Introduceti data nasterii sub forma zz.ll: ";
  35. cin>>numar;
  36. ziua=floor(numar);
  37. numar=numar*100;
  38. luna=floor(numar);
  39. luna=luna%100;
  40.  
  41. data=name1+".data";
  42. date.open(data.c_str());
  43. if((ziua>0 && ziua<10)&&(luna>0 && luna<10))
  44. date<<"0"<<ziua<<".0"<<luna;
  45. else
  46. date<<ziua<<"."<<luna;
  47. date.close();
  48.  
  49. string zodie("Va rugam sa reincercati ");
  50.  
  51. if(ziua>31 || ziua<0 || ziua==0 )
  52. cout<<"Zi invalida"<<endl;
  53.  
  54. if (luna>12 || luna<0 || luna==0 )
  55.  
  56. cout<<"Luna invalida"<<endl;
  57. if((luna==3 && ziua>=21 && ziua<=31 )||(luna==4 && ziua<=20))
  58. zodie="BERBEC";
  59. else
  60. if((luna==4 && ziua>=21 && ziua<=30 )||(luna==5 && ziua<=20))
  61. zodie="TAUR";
  62. else
  63. if((luna==5 && ziua>=21 && ziua<=31) || (luna==6 && ziua<=21))
  64. zodie="GEMENI";
  65. else
  66. if((luna==6 && ziua>=22 && ziua<=30)||(luna==7 && ziua<=22))
  67. zodie="RAC";
  68. else
  69. if((luna==7 && ziua>=23 && ziua<=31)||(luna==8 && ziua<=22))
  70. zodie="LEU";
  71. else
  72. if((luna==8 && ziua>=23 && ziua<=31)||(luna==9 && ziua<=22))
  73. zodie="FECIOARA";
  74. else
  75. if((luna==9 && ziua>=23 && ziua<=30)||(luna==10 && ziua<=22))
  76. zodie="BALANTA";
  77. else
  78. if((luna==10 && ziua>=23 && ziua<=31)||(luna==11 && ziua<=21))
  79. zodie="SCORPION";
  80. else
  81. if((luna==11 && ziua>=22 && ziua<=30)||(luna==12 && ziua<=20))
  82. zodie="SAGETATOR";
  83. else
  84. if((luna==12 && ziua>=21 && ziua<=31)||(luna==1 && ziua<=19))
  85. zodie="CAPRICORN";
  86. else
  87. if((luna==1 && ziua>=20 && ziua<=31)||(luna==2 && ziua<=18))
  88. zodie="VARSATOR";
  89. else
  90. if((luna==2 && ziua>=19 && ziua<=28)||(luna==3 && ziua<=20))
  91. zodie="PESTI";
  92.  
  93. ofstream zodiac ;
  94. string zodile ;
  95. zodile=name1+".zodia";
  96. zodiac.open(zodile.c_str());
  97. zodiac<<zodie;
  98. zodiac.close();
  99.  
  100. cout<<zodie<<endl;
  101.  
  102. }
  103. if(command=='1'){
  104. string name2;
  105. string name3;
  106. cout<<"Va rugam sa intoduceti un nume care face sau nu parte din evidenta: ";
  107. cin>>name3;
  108. ifstream nume("Catalog.txt",ifstream::app);
  109. if (nume.is_open())
  110. {
  111. while ( getline (nume,name2) )
  112. {
  113. if(name2!=name3)
  114. cout<<"Nu am gasit aceasta persoana in evidenta naostra"<<endl;
  115.  
  116. if(name2==name3){
  117. cout<< name3 << " nascut(a) pe ";
  118. ifstream date;
  119. string numar2;
  120. date.open((name3+".data").c_str());
  121. if(date.is_open())
  122. {
  123. getline(date,numar2);
  124. cout<<numar2<<" este in zodia ";
  125.  
  126. string zodie2;
  127. ifstream zodile;
  128. zodile.open((name3+".zodia").c_str());
  129. if(zodile.is_open()){
  130. getline(zodile,zodie2);
  131. cout<<zodie2<<endl;
  132. }
  133. zodile.close();
  134. }
  135. date.close();
  136. }
  137. nume.close();
  138. }
  139. }
  140.  
  141. }
  142. if(command=='2'){
  143. string line;
  144. int names=0;
  145. string zodie3;
  146. string zodie4;
  147. string zodie5;
  148. int n_persoane=0;
  149. cout<<"Intoduce o zodie CU MAJUSCULE sa vedem cator persoane din evidenta le apartine: ";
  150. cin>>zodie5;
  151. ifstream zodile;
  152. ifstream nume ("Catalog.txt",ifstream::app);
  153. if (nume.is_open())
  154. {
  155. while ( getline (nume,line) )
  156. {
  157. names++;
  158. zodile.open((line+".zodia").c_str(),ifstream::app);
  159. if(zodile.is_open()){
  160. getline(zodile,zodie4);
  161. if(zodie5==zodie4){
  162. n_persoane++;
  163. }
  164. }
  165. zodile.close();
  166. }
  167. }
  168. nume.close();
  169. cout<<"In evidenta noastra se afla "<<names<<" persoane "<<endl;
  170. if(n_persoane==0)
  171. cout<<"Aceasta zodie nu apartine nimanui "<<endl;
  172. else
  173. cout<<"Zodia "<<zodie4<<" apartine "<<n_persoane<<" persoane"<<endl;
  174. }
  175. if(command!='x'){
  176. cout<<"Daca doriti sa parasiti apasati x "<<endl;
  177. }
  178. }
  179. return 0;
  180. }
RAW Paste Data