fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6. /*
  7. *Коротко о программе: программа создана для подсчёта проданных книг(по количеству,имени, цене)
  8. */
  9.  
  10.  
  11.  
  12.  
  13. class MainProgramCore {
  14. public:
  15. ofstream fout;
  16. void getNameAndPrice() {
  17. int price = 0;
  18. string name = "";
  19. fout.open("soldbooks.txt", ios_base::app);
  20. cout << "Hello. I'am your own helper! Type name then press enter and type price!";
  21. cin >> name >> price;
  22. fout << name << ":" << price << "$\n";
  23. fout.close();
  24. }
  25. void countAmount() {
  26. char *str = new char[1024];
  27. int amount = 0;
  28. ifstream iout("soldbooks.txt");
  29. while (!iout.eof())
  30. {
  31. iout.getline(str, 1024, '\n');
  32. amount++;
  33. }
  34. cout << "You sold: " << amount-1 << " books! \n ";
  35. delete str;
  36. }
  37. void countTotalEarned() {
  38.  
  39. }
  40. };
  41.  
  42. // Объявление переменных
  43. void mainViarables();
  44. int price, number, amount;
  45. string name, answer;
  46.  
  47. int main() {
  48. MainProgramCore objMainProgramCore;
  49. objMainProgramCore.countAmount();
  50. objMainProgramCore.countTotalEarned();
  51. cout << "Hello! If you sold any book, type Y. If you didn't, just ignore this message! : ";
  52. cin >> answer;
  53. if ((answer == "Y") || (answer == "y")) {
  54. cout << "Ok! How much books did you sell? Type number: ";
  55. cin >> number;
  56. for (int i = 0; i < number; i++) {
  57. objMainProgramCore.getNameAndPrice();
  58. }
  59. system("pause");
  60. return 0;
  61.  
  62. }
  63. }
  64.  
  65.  
  66.  
  67.  
Time limit exceeded #stdin #stdout 5s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty