Advertisement
Guest User

2

a guest
Jun 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <stdlib.h>
  4. #include <string>
  5. #include <vector>
  6. using namespace std;
  7.  
  8. struct Shoes {
  9.   string name;
  10.   string season;
  11.   string producer;
  12.   int price;
  13.   int year;
  14. };
  15.  
  16. int main() {
  17.   setlocale(LC_ALL, "Russian");
  18.   vector<Shoes> shoesVector;
  19.   ifstream fin("input.txt");
  20.   ofstream fout("output.txt");
  21.  
  22.   while (!fin.eof()) {
  23.     Shoes shoes;
  24.     fin >> shoes.name >> shoes.season >> shoes.producer >> shoes.price >> shoes.year;
  25.     shoesVector.push_back(shoes);
  26.   }
  27.  
  28.   int totalAmount = 0;
  29.   for (int i = 0; i < shoesVector.size(); i++) {
  30.     Shoes currentShoes = shoesVector[i];
  31.     if (currentShoes.year > 2014) {
  32.       totalAmount += currentShoes.price;
  33.       fout << currentShoes.name << ' ' << currentShoes.season << ' '
  34.         << currentShoes.producer << ' ' << currentShoes.price
  35.         << ' ' << currentShoes.year << '\n';
  36.     }
  37.   }
  38.  
  39.   fout << "Общая цена: " << totalAmount;
  40.  
  41.   return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement