Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <windows.h>
- #include <string>
- #define N 20
- using namespace std;
- struct product {
- int shop_num=0;
- string familia;
- string name;
- int kol=0;
- int cost=0;
- };
- int main() {
- SetConsoleCP(1251);// перевод на русский
- SetConsoleOutputCP(1251);
- ifstream A("exam.txt"); //открыли файл для чтения
- product M[N];
- for (int i = 0; i < N; i++) //считываем информацию с файла
- {
- A.ignore(255, '\n');
- A >> M[i].shop_num;
- A >> M[i].familia;
- A >> M[i].name;
- A >> M[i].kol;
- A >> M[i].cost;
- }
- for (int i = 0; i < N; i++) //вычисляем сумму
- {
- int summ = M[i].kol * M[i].cost;
- cout << "Номер магазина: " << M[i].shop_num << " Товара на сумму: " << summ << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment