Advertisement
Guest User

Untitled

a guest
May 25th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <string>
  4. #include <fstream>
  5. #include <ctime>
  6. #include <vector>
  7. using namespace std;
  8. struct List
  9. {
  10. int num;
  11. string data;
  12. List *next;
  13. };
  14. class Books
  15. {
  16. public:
  17. int schetchik, sumastr;
  18. private:
  19. int poryadok, glavy, strglavy;
  20. ifstream f1;
  21. string Name;
  22. vector <int> strknig;
  23. string name[20];
  24. int i, b;
  25. void StrKn(int glavy)
  26. {
  27. for (int i = 0; i < glavy; i++)
  28. {
  29. strknig.push_back(rand() % 100 - 50);
  30. }
  31. }
  32. void SumStr(vector <int> strknig, int glavy)
  33. {
  34. sumastr = 0;
  35. for (int i = 0; i < glavy; i++)
  36. {
  37. sumastr += strknig[i];
  38. }
  39. cout << sumastr << "Страниц в книге" << endl;
  40. }
  41. public:
  42. void Glavy()
  43. {
  44. int glavy;
  45. glavy = rand() % 11 - 5;
  46. }
  47. void Vyvod(string Name, int glavy, int b, vector <int> strknig)
  48. {
  49. cout << b << " " << Name << " " << glavy << " ";
  50. for (int i = 1; i < glavy; i++)
  51. {
  52. cout << i << "глава" << strknig[i] << "страниц, ";
  53. }
  54. cout << sumastr << "страниц всего.";
  55. }
  56. Books()
  57. {
  58. i = 0;
  59. b = 1;
  60. f1.open ("C:\Kniga.txt");
  61. while (!f1.eof())
  62. {
  63. f1 >> name[i];
  64. i++;
  65. }
  66. i = rand() % 20;
  67. Name = name[i];
  68. Glavy();
  69. StrKn(glavy);
  70. SumStr(strknig, glavy);
  71. Vyvod(Name, glavy, b, strknig);
  72. }
  73. };
  74. void main()
  75. {
  76. const int Bk = 20;
  77. Books Bo[Bk];
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement