Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. typedef struct ajto{
  5. int ora;
  6. int perc;
  7. int az;
  8. string irany;
  9. } ajto;
  10.  
  11.  
  12. int main()
  13. {
  14. fstream f;
  15. f.open("ajto.txt",ios::in);
  16. ajto t[1000];
  17. int i=1;
  18. while(!f.eof()){
  19. f>>t[i].ora;
  20. f>>t[i].perc;
  21. f>>t[i].az;
  22. f>>t[i].irany;
  23. i++;
  24. }
  25. int db=i-2;
  26. cout<<t[5].irany<<endl;
  27. cout<<db<<endl;
  28. cout<<"1. Feladat"<<endl;
  29. i=1;
  30. while(i<=db){
  31. if(t[i].irany=="be"){
  32. cout<<t[i].az<<"ment be elsokent"<<endl;
  33. break;
  34. }
  35. i++; cout<<"1. Feladat"<<endl;
  36.  
  37. }
  38. i=db;
  39. while(i>=0){
  40. if(t[i].irany=="ki"){
  41. cout<<t[i].az<<"ment ki utoljara"<<endl;;
  42. break;
  43. }
  44. i--;
  45. }
  46. cout<<"2. Feladat"<<endl;
  47. int a=1;
  48. int z[100];
  49.  
  50. i=1;
  51. while(a<=100){
  52. i=1;
  53. while(i<=db){
  54. if(t[i].az==a)z[a]++;
  55. i++;
  56. }
  57. a++;
  58. }
  59.  
  60. cout<<z[1]<<endl;
  61.  
  62.  
  63. f.close();
  64. f.open("athaladas.txt",ios::out);
  65. i=1;
  66. while(i<42){
  67. if(z[i]==0)i++;
  68. else{f<<i;
  69. f<<" ";
  70. f<<z[i];
  71. f<<" ";
  72. f<<endl;
  73. i++;}
  74. }
  75. f.close();
  76. return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement