Advertisement
Seal_of_approval

2p67

Dec 9th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <string>
  5. using namespace std;
  6. ifstream inp ("input.txt");
  7. ofstream out ("output.txt");
  8. struct car
  9. {
  10. string mark, surname;
  11. int number, year, km;
  12. void print();
  13. };
  14. void car::print()
  15. {
  16. out <<setw(6)<<mark<<setw(15)<<surname<<setw(6)<<number<<setw(4)<<year<<setw(5)<<km<<endl;
  17. }
  18. int main (void)
  19. {
  20. int n;
  21. cin >> n;
  22. car *cars = new car[n];
  23. n=0;
  24. while (inp.peek() != EOF)
  25. {
  26. inp >> cars[n].mark;
  27. inp >> cars[n].surname;
  28. inp >> cars[n].number;
  29. inp >> cars[n].year;
  30. inp >> cars[n].km;
  31. n++;
  32. }
  33. inp.close();
  34. int ayear;
  35. cin >> ayear;
  36. for (int i=0; i<n; i++)
  37. if (ayear > cars[i].year)
  38. cars[i].print();
  39. out.close();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement