Guest User

Untitled

a guest
Jun 12th, 2014
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include "iostream"
  2. #include "fstream"
  3. #include "string"
  4. #include "sstream"
  5. #include "stdlib.h"
  6. #include "conio.h"
  7.  
  8. using namespace std;
  9.  
  10.  
  11. struct Spetent
  12. {
  13. int numer;
  14. int pin;
  15. float kwota;
  16. };
  17.  
  18. class BAZA
  19. {
  20. public:
  21. Spetent petent[20];
  22.  
  23. BAZA()
  24. {
  25. for(int i = 0; i<20; i++ )
  26. {
  27. petent[i].numer = 0;
  28. petent[i].pin = 0;
  29. petent[i].kwota = 0;
  30.  
  31. }
  32. }
  33.  
  34.  
  35. void Pobierz()
  36. {
  37. ifstream pobierz("dane.txt");
  38. string linia;
  39. int spacja = 0;
  40. int index = 0;
  41. while(getline(pobierz,linia))
  42. {
  43. for(int i = 0; i < 20; i++)
  44. {
  45. string bufor("");
  46. if(linia[i] == ' ') ++i;
  47. while(linia[i] != ' ')
  48. {
  49. bufor += linia[i];
  50. if(i+1 == linia.size()) break;
  51. else if(linia[i+1] == ' ') break;
  52. ++i;
  53. }
  54. stringstream temp; temp.clear();
  55. temp << bufor;
  56. if(spacja == 0) temp >> petent[index].numer;
  57. if(spacja == 1) temp >> petent[index].pin;
  58. if(spacja == 2) temp >> petent[index].kwota;
  59. ++spacja;
  60. if(spacja == 3)
  61. {
  62. spacja = 0;
  63. index++;
  64. }
  65.  
  66. }
  67. }
  68. }
  69.  
  70. void zapisz()
  71. {
  72. ofstream zapisz("danee.txt");
  73. for(int i = 0; i < 20; i++)
  74. {
  75. zapisz << petent[i].numer << " " << petent[i].pin << " " << petent[i].kwota << "\n";
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment