Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. //main
  2.  
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6. #include <iomanip>
  7.  
  8. using namespace std;
  9.  
  10. #include "class.h"
  11.  
  12. const int x = 14;
  13.  
  14. int main()
  15. {
  16. ifstream infile;
  17. ofstream outfile;
  18.  
  19. infile.open("Text.txt");
  20. outfile.open("outfile.txt");
  21.  
  22. record data[100];
  23. int i = 0;
  24. string a, b;
  25. double c, d;
  26.  
  27. outfile << setprecision(10);
  28.  
  29. while (infile)
  30. {
  31. getline(infile, a);
  32. getline(infile, b);
  33. infile >> c >> d;
  34. infile.ignore(100, '\n');
  35. if (data[i].load(a, b, c, d))
  36. {
  37. i++;
  38. }
  39. }
  40.  
  41. for (int j = 0; j < i; j++)
  42. {
  43. data[j].retriveData(a, b, c, d);
  44. outfile << setw(x) << a << setw(x) << b
  45. << setw(x) << c << setw(x) << d << endl;
  46. }
  47.  
  48. for (int z = 0; z < i; z++)
  49. {
  50. for (int y = 0; y < i; y++)
  51. {
  52. if (data[z].getId() < data[y].getId())
  53. {
  54. swap(data[z], data[y]);
  55. }
  56. }
  57. }
  58.  
  59. outfile << endl << endl;
  60.  
  61. for (int j = 0; j < i; j++)
  62. {
  63. data[j].retriveData(a, b, c, d);
  64. outfile << setw(x) << a << setw(x) << b
  65. << setw(x) << c << setw(x) << d << endl;
  66. }
  67.  
  68. infile.close();
  69. outfile.close();
  70.  
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement