Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <string.h>
- struct CIVILIAN {
- char surname[13];
- char district[15];
- char social[15];
- double value;
- };
- using namespace std;
- int main() {
- setlocale(LC_ALL, "Rus");
- int max = 0;
- short choise;
- FILE *fp;
- CIVILIAN *group = new CIVILIAN;
- bool k = false;
- do {
- cout << "\nМЕНЮ: \n";
- cout << "1.Добавить вкладчика.\n";
- cout << "2.Таблица вкладчиков.\n";
- cout << "3.Служащие вкладчики.\n";
- cout << "0.Выход.\n";
- cout << "Выбор : ";
- cin >> choise;
- if (choise == 1) {
- system("cls");
- fp = fopen("test.dat", "ab");
- cin.ignore();
- cout << "Фамилия : ";
- cin.getline(group->surname, 13);
- cout << "Район : ";
- cin.getline(group->district, 15);
- cout << "Соц.положение : ";
- cin.getline(group->social, 15);
- cout << "величина вклада : ";
- cin >> group->value;
- k = true;
- fwrite(group, sizeof(CIVILIAN), 1, fp);
- fclose(fp);
- system("cls");
- }
- if ((choise == 2) && (k)) {
- system("cls");
- max = 0;
- int pc = 0;
- fp = fopen("test.dat", "rb");
- while (!feof(fp)) {
- fread(group, sizeof(CIVILIAN), 1, fp);
- if (!feof(fp)) {
- cout << "ТАБЛИЦА О ВКЛАДЧИКАХ ::\n";
- cout << "\tФамилия : " << group->surname << endl;
- cout << "\tРайон : " << group->district << endl;
- if (strcmp(group->social, "Служащий") == 0) pc++;
- cout << "\tСоц.положение : " << group->social << endl;
- cout << "\tВеличина вклада : " << group->value << endl;
- cout << "\nКоличество служащих : " << pc << endl;
- }
- }
- system("pause");
- fclose(fp);
- }
- if ((choise == 3) && (k)) {
- fp = fopen("test.dat", "rb");
- while (fread(group, sizeof(CIVILIAN), 1, fp) == 1) {
- if (strcmp(group->social, "Служащий") == 0) {
- cout << "ТАБЛИЦА О ВКЛАДЧИКАХ ::\n";
- cout << "\tФамилия : " << group->surname << endl;
- cout << "\tРайон : " << group->district << endl;
- cout << "\tСоц.положение : " << group->social << endl;
- cout << "\tВеличина вклада : " << group->value << endl;
- }
- }
- fclose(fp);
- }
- } while (choise);
- delete group;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement