Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // generator smiesznych memuw na wektorach
  4. //
  5. // Created by Piotr Neska on 11.12.2016.
  6. // Copyright © 2016 Piotr Neska. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <fstream>
  11. #include <vector>
  12. #include <string>
  13.  
  14. int zlicz(std::string gdzie) {
  15. std::ifstream liczony(gdzie);
  16.  
  17. // new lines will be skipped unless we stop it from happening:
  18. liczony.unsetf(std::ios_base::skipws);
  19.  
  20. // count the newlines with an algorithm specialized for counting:
  21. unsigned line_count = std::count(
  22. std::istream_iterator<char>(liczony),
  23. std::istream_iterator<char>(),
  24. '\n');
  25.  
  26. //std::cout << "Linie w " << gdzie << ": " << line_count << "\n";
  27. return line_count;
  28. }
  29.  
  30. int main(int argc, const char * argv[]) {
  31.  
  32. int linieprefixy=zlicz("prefixy");
  33. int liniefixy=zlicz("fixy");
  34. int liniesufixy=zlicz("sufixy");
  35.  
  36. //std::cout << "ZAKONCZYLEM ZLICZANIE\n";
  37.  
  38. std::fstream prefixy;
  39. prefixy.open ("prefixy",std::ios::in); // imie
  40. std::fstream fixy;
  41. prefixy.open ("fixy",std::ios::in); // rasa
  42. std::fstream sufixy;
  43. sufixy.open ("sufixy",std::ios::in); // rola
  44.  
  45. //std::cout << "ZAKONCZYLEM WCZYTYWANIE PLIKOW\n";
  46.  
  47. std::string line;
  48. std::vector<std::string> tabprefixy;
  49. std::vector<std::string> tabfixy;
  50.  
  51. while (std::getline(prefixy, line))
  52. {
  53. tabprefixy.push_back(line);
  54. }
  55.  
  56. while (std::getline(fixy, line))
  57. {
  58. tabfixy.push_back(line);
  59. }
  60.  
  61. //std::cout << "ZAKONCZYLEM CZYTANIE PLIKOW\n";
  62.  
  63. int i;
  64. for(i=0;i<tabprefixy.size();i++)std::cout<<tabprefixy[i]<<"\n";
  65. for(i=0;i<tabfixy.size();i++)std::cout<<tabfixy[i]<<"\n";
  66.  
  67.  
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement