Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.19 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct data
  5. {
  6. string username;
  7. int problemsSubmitted, problemsSolved;
  8. data()
  9. {
  10. username="";
  11. problemsSubmitted=0;
  12. problemsSolved=0;
  13. }
  14. };
  15.  
  16.  
  17. struct UVA
  18. {
  19. string nm, cntry, handle, univ;
  20. int solved;
  21. UVA()
  22. {
  23. solved=0;
  24. }
  25. };
  26.  
  27. bool compare1(UVA l, UVA r){
  28. if(l.solved>r.solved)return true;
  29. if(l.solved==r.solved && l.nm<r.nm)return true;
  30. return false;
  31. }
  32.  
  33. struct LIGHTOJ
  34. {
  35. string nm, cntry, handle, univ;
  36. int solved;
  37. LIGHTOJ()
  38. {
  39. solved=0;
  40. }
  41. };
  42.  
  43. bool compare2(LIGHTOJ l, LIGHTOJ r){
  44. if(l.solved>r.solved)return true;
  45. if(l.solved==r.solved && l.nm<r.nm)return true;
  46. return false;
  47. }
  48.  
  49. struct CODEFORCES
  50. {
  51. string nm, cntry, handle, univ;
  52. int solved;
  53. CODEFORCES()
  54. {
  55. solved=0;
  56. }
  57. };
  58.  
  59. bool compare3(CODEFORCES l, CODEFORCES r){
  60. if(l.solved>r.solved)return true;
  61. if(l.solved==r.solved && l.nm<r.nm)return true;
  62. return false;
  63. }
  64.  
  65. class persons
  66. {
  67. protected:
  68. string name;
  69. string countryName;
  70. int age;
  71.  
  72. public:
  73. void setName()
  74. {
  75. cout<<"Enter Name:: ";
  76. cin>>name;
  77. }
  78. void setCountryName()
  79. {
  80. cout<<"Enter Country Name:: ";
  81. cin>>countryName;
  82. }
  83. void setAge()
  84. {
  85. cout<<"Enter Age:: ";
  86. cin>>age;
  87. }
  88. string getName()
  89. {
  90. return name;
  91. }
  92. string getCountryName()
  93. {
  94. return countryName;
  95. }
  96. int getAge()
  97. {
  98. return age;
  99. }
  100.  
  101. };
  102. class students:public persons
  103. {
  104. protected:
  105. string institute;
  106. string dept;
  107.  
  108. public:
  109. students()
  110. {
  111. institute="";
  112. dept="";
  113. }
  114. void setName()
  115. {
  116. persons::setName();
  117. }
  118. void setCountryName()
  119. {
  120. persons::setCountryName();
  121.  
  122. }
  123. void setAge()
  124. {
  125. persons::setAge();
  126. }
  127. string getName()
  128. {
  129. return persons:: getName();
  130. }
  131. string getCountryName()
  132. {
  133. return persons::getCountryName();
  134. }
  135. int getAge()
  136. {
  137. return persons::getAge();
  138. }
  139. void setInstitute()
  140. {
  141. cout<<"Enter Institutions Name:: ";
  142. cin>>institute;
  143. }
  144. void setDept()
  145. {
  146. cout<<"Enter Department Name:: ";
  147. cin>>dept;
  148. }
  149. string getInstitute()
  150. {
  151. return institute;
  152. }
  153. string getDept()
  154. {
  155. return dept;
  156. }
  157.  
  158.  
  159. };
  160. class programmer:public students
  161. {
  162. private:
  163. data uva, lightOJ, codeforces;
  164.  
  165. public:
  166. programmer()
  167. {
  168. uva.username="";
  169. uva.problemsSubmitted=0;
  170. uva.problemsSolved=0;
  171. lightOJ.username="";
  172. lightOJ.problemsSubmitted=0;
  173. lightOJ.problemsSolved=0;
  174. codeforces.username="";
  175. codeforces.problemsSubmitted=0;
  176. codeforces.problemsSolved=0;
  177.  
  178. }
  179. void setName()
  180. {
  181. students::setName();
  182. }
  183. void setCountryName()
  184. {
  185. students::setCountryName();
  186.  
  187. }
  188. void setAge()
  189. {
  190. students::setAge();
  191. }
  192. string getName()
  193. {
  194. return name;
  195. }
  196. string getCountryName()
  197. {
  198. return countryName;
  199. }
  200. int getAge()
  201. {
  202. return age;
  203. }
  204.  
  205. void setInstitute()
  206. {
  207. students::setInstitute();
  208. }
  209. void setDept()
  210. {
  211. students::setDept();
  212. }
  213. string getInstitute()
  214. {
  215. return students::getInstitute();
  216. }
  217. string getDept()
  218. {
  219. return students::getDept();
  220. }
  221.  
  222. void getUvaRecords()
  223. {
  224. cout<<"Enter UVA username: ";
  225. cin>>uva.username;
  226. cout<<"Enter Number of problems submitted: ";
  227. cin>>uva.problemsSubmitted;
  228. cout<<"Enter Number of problems solved: ";
  229. cin>>uva.problemsSolved;
  230. }
  231.  
  232. void getLightOJRecords()
  233. {
  234. cout<<"Enter LightOJ username: ";
  235. cin>>lightOJ.username;
  236. cout<<"Enter Number of problems submitted: ";
  237. cin>>lightOJ.problemsSubmitted;
  238. cout<<"Enter Number of problems solved: ";
  239. cin>>lightOJ.problemsSolved;
  240. }
  241.  
  242. void getCodeforcesRecords()
  243. {
  244. cout<<"Enter Codeforces username: ";
  245. cin>>codeforces.username;
  246. cout<<"Enter Number of problems submitted: ";
  247. cin>>codeforces.problemsSubmitted;
  248. cout<<"Enter Number of problems solved: ";
  249. cin>>codeforces.problemsSolved;
  250. }
  251.  
  252.  
  253. };
  254.  
  255. class allStudents
  256. {
  257. students arrS[100];
  258.  
  259. int numberOfStudents;
  260.  
  261. public:
  262. allStudents()
  263. {
  264. numberOfStudents=0;
  265. }
  266.  
  267. void getInput()
  268. {
  269. cout<<"Enter informations of student "<<++numberOfStudents<<" :"<<endl;
  270. arrS[numberOfStudents].setName();
  271. arrS[numberOfStudents].setCountryName();
  272. arrS[numberOfStudents].setAge();
  273. arrS[numberOfStudents].setInstitute();
  274. arrS[numberOfStudents].setDept();
  275. }
  276. void displayAllStudents()
  277. {
  278. cout<<"Informations of all students:: "<<endl<<endl;
  279. for(int i=1; i<=numberOfStudents; i++)
  280. {
  281. cout<<"Students Number:: "<<i<<endl;
  282. cout<<"Name:: "<<arrS[i].getName()<<endl;
  283. cout<<"Country:: "<<arrS[i].getCountryName()<<endl;
  284. cout<<"Age:: "<<arrS[i].getAge()<<endl;
  285. cout<<"Institution:: "<<arrS[i].getInstitute()<<endl;
  286. cout<<"Department:: "<<arrS[i].getDept()<<endl;
  287. }
  288. }
  289.  
  290. };
  291.  
  292. class allProgrammers
  293. {
  294.  
  295. programmer arrP[100];
  296. UVA arrayUva[100];
  297. LIGHTOJ arrayLightoj[100];
  298. CODEFORCES arrayCodeforces[100];
  299. int numberOfProgrammers;
  300.  
  301. public:
  302. allProgrammers()
  303. {
  304. numberOfProgrammers=0;
  305. }
  306. void getInput()
  307. {
  308. cout<<"Enter programmer number "<<++numberOfProgrammers<<" ::"<<endl<<endl;
  309. arrP[numberOfProgrammers].setName();
  310. arrP[numberOfProgrammers].setCountryName();
  311. arrP[numberOfProgrammers].setAge();
  312. arrP[numberOfProgrammers].setInstitute();
  313. arrP[numberOfProgrammers].setDept();
  314. arrP[numberOfProgrammers].getUvaRecords();
  315. arrP[numberOfProgrammers].getCodeforcesRecords();
  316. arrP[numberOfProgrammers].getLightOJRecords();
  317. }
  318. void getAllProgrammersInformation()
  319. {
  320. for(int i=1; i<=numberOfProgrammers; i++)
  321. cout<<"Students Number:: "<<i<<endl;
  322. cout<<"Name:: "<<arrP[i].getName()<<endl;
  323. cout<<"Country:: "<<arrP[i].getCountryName()<<endl;
  324. cout<<"Age:: "<<arrP[i].getAge()<<endl;
  325. cout<<"Institution:: "<<arrP[i].getInstitute()<<endl;
  326. cout<<"Department:: "<<arrP[i].getDept()<<endl;
  327.  
  328. }
  329.  
  330. void updateRanklist()
  331. {
  332. for(int i=1; i<=numberOfProgrammers; i++)
  333. {
  334. arrayUva[i].nm=arrP[i].getName();
  335. arrayUva[i].cntry=arrP[i].getCountryName();
  336. arrayUva[i].handle=arrP[i].uva.username;
  337. arrayUva[i].univ=arrP[i].getInstitute();
  338. arrayUva[i].solved=arrP[i].uva.problemsSolved;
  339.  
  340. }
  341. sort(arrayUva+1, arrayUva+1+numberOfProgrammers);
  342.  
  343. for(int i=1; i<=numberOfProgrammers; i++)
  344. {
  345. arrayCodeforces[i].nm=arrP[i].getName();
  346. arrayCodeforces[i].cntry=arrP[i].getCountryName();
  347. arrayCodeforces[i].handle=arrP[i].codeforces.username;
  348. arrayCodeforces[i].univ=arrP[i].getInstitute();
  349. arrayCodeforces[i].solved=arrP[i].codeforces.problemsSolved;
  350.  
  351. }
  352. sort(arrayCodeforces+1, arrayCodeforces+1+numberOfProgrammers);
  353. for(int i=1; i<=numberOfProgrammers; i++)
  354. {
  355. arrayLightoj[i].nm=arrP[i].getName();
  356. arrayLightoj[i].cntry=arrP[i].getCountryName();
  357. arrayLightoj[i].handle=arrP[i].lightOJ.username;
  358. arrayLightoji].univ=arrP[i].getInstitute();
  359. arrayLightoj[i].solved=arrP[i].lightOJ.problemsSolved;
  360.  
  361. }
  362. sort(arrayLightoj+1, arrayLightoj+1+numberOfProgrammers);
  363.  
  364.  
  365. }
  366.  
  367.  
  368. };
  369.  
  370. int main()
  371. {
  372. allStudents s;
  373. allProgrammers p;
  374. p.getInput();
  375. p.displayAllStudents();
  376.  
  377. return 0;
  378. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement