Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <string>
  5.  
  6. struct Sorter {
  7. private:
  8.     std::vector<std::string> block; //a blocks
  9.     std::size_t number;            //N
  10.     std::size_t counter;           //K
  11. public:
  12.     Sorter();
  13.     Sorter(std::string path);
  14.     ~Sorter();
  15.     std::string setBlock  (std::string node);
  16.     std::size_t setNumber (std::size_t number );
  17.     std::size_t setCounter(std::size_t counter);
  18.     void setAllBlocks(std::fstream file, std::size_t start = 2);
  19.     std::string getBlock();
  20.     std::size_t getNumber();
  21.     std::size_t getCounter();
  22.     bool init(std::string path);
  23.     Sorter& sort();
  24. };
  25.  
  26. int main()
  27. {
  28.     Sorter sorter;
  29.     std::string path_to_file = "C:\Users\Administrator\Desktop
  30.  
  31. \test.txt";
  32.     std::size_t N, K;
  33.     std::vector<std::string> vec;
  34.     std::fstream file;
  35.     file.open(path_to_file);
  36.     file >> N;
  37.     file >> K;
  38.     std::cout << N << " " << K << "\n";
  39.  
  40.     file.close();
  41.     return 0;
  42. }
  43.  
  44. Sorter::Sorter() : number{0},
  45.                    counter{0}
  46. {}
  47.  
  48. Sorter::Sorter(std::string path)
  49. {
  50.     init(path);
  51. }
  52.  
  53. Sorter::~Sorter()
  54. {}
  55.  
  56. std::string Sorter::setBlock(std::string node)
  57. {
  58.     block.push_back(node);
  59.    
  60.     return node;
  61. }
  62.  
  63. std::size_t Sorter::setNumber(std::size_t number)
  64. {
  65.     return this->number = number;
  66. }
  67.  
  68. std::size_t Sorter::setCounter(std::size_t counter)
  69. {
  70.     return this->counter = counter;
  71. }
  72.  
  73. void setAllBlocks(std::fstream file, std::size_t start)
  74. {
  75.     while ( !file.eof() ) {
  76.         //write strings to blocks
  77.         //////////////////////////////////////////////////////
  78.     }
  79. }
  80.  
  81. bool Sorter::init(std::string path)
  82. {
  83.     // like in main()
  84.     std::fstream file;
  85.     file.open(path);
  86.     if (!file.is_open()) {
  87.         return 1;
  88.     }
  89.     //////////////////////////////////////////////////////////////
  90.     return 0;
  91. }
  92.  
  93. Sorter& Sorter::sort()
  94. {
  95.     //////////////////////////////////////////////
  96.     return *this;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement