Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- #include <locale>
- using namespace std;
- struct prod {
- char shifr[16];
- char name[16];
- char izm[16];
- int plan;
- int res;
- };
- void main()
- {
- setlocale(LC_ALL, "Russian");
- ofstream fout("f.dat", ios::binary | ios::out);
- char code;
- cout << "Ввести продукцию? y - да, любой другой символ - нет" << endl;
- cin >> code;
- prod a;
- while (code == 'y' || code == 'у') {
- cout << endl;
- cout << "Введите шифр продукции" << endl;
- cin >> a.shifr;
- cout << "Введите наименование продукции" << endl;
- cin >> a.name;
- cout << "Введите единицу измерения продукции" << endl;
- cin >> a.izm;
- cout << "Введите план выпуска продукции" << endl;
- cin >> a.plan;
- cout << "Введите фактический выпуск продукции" << endl;
- cin >> a.res;
- fout.write((char*)&a, sizeof a);
- cout << endl;
- cout << "Ввести продукцию? y - да, любой другой символ - нет" << endl;
- cin >> code;
- }
- fout.close();
- ifstream fin("f.dat", ios::binary | ios::in);
- cout << endl;
- cout << setw(16) << "Шифр" << " "
- << setw(16) << "Наименование" << " "
- << setw(16) << "Ед. измерения" << " "
- << setw(16) << "План" << " "
- << setw(16) << "Выпуск" << " "
- << setw(16) << "Недовыполнение" << endl;
- while (fin.read((char*)&a, sizeof prod)) {
- if (a.res < a.plan) {
- cout << setw(16) << a.shifr << " "
- << setw(16) << a.name << " "
- << setw(16) << a.izm << " "
- << setw(16) << a.plan << " "
- << setw(16) << a.res << " "
- << setw(15) << (((a.plan - a.res) * 1.0) / (a.plan)) * 100 << "%" << endl;
- }
- }
- fin.close();
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement