SHARE
TWEET

2

a guest Jun 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top