Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <limits>
- using namespace std;
- //открываем глобальные файловые потоки
- ifstream in("input.txt");
- ofstream out("output.txt");
- struct vedomost
- {
- int price, amount;
- string vid, sort;
- void print(float x); //член-функция для вывода информации в файл
- };
- void vedomost::print(float x)
- {
- out << setw(10) << vid << setw(10) << x*(float)price << setw(10) << sort << setw(10) << amount << endl;
- }
- int main()
- {
- int n; cout << "Введите число наименований (продуктов): "; cin >> n;
- vedomost* product = new vedomost[n];
- float x;
- cout << "Стоимость каждого вида продукции увеличена на (процентов): ";
- cin >> x;
- x /= 100; x += 1;
- n = 0; //значение n больше не нужно, воспользуемся этой переменной для нумерации элементов массива
- while (in.peek() != EOF)
- {
- in >> product[n].vid;
- in >> product[n].price;
- in >> product[n].sort;
- in >> product[n].amount;
- product[n].print(x);
- ++n;
- }
- in.close();
- out.close();
- delete[] product;
- return 0;
- }
Add Comment
Please, Sign In to add comment