
Добавил:
BlackCat
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:2 семестр ФИБС / Информатика / 1 практика / FIO_PR1_2_1_Default
.cpp#include <iostream>
#include <string.h>
#include <clocale>
#include <malloc.h>
#include <cstdio>
using namespace std;
struct stuff
{
char name[25];
char surname[25];
char titul[25];
int number;
int money;
};
void scan_inform(struct stuff *man, int n)
{
for (int i=0; i<n; i++)
{
printf("Номер сотрудника:\t");
scanf("%d",&man[i].number);
printf("Имя сотрудника:\t");
scanf("%s",man[i].name);
printf("Фамилия сотрудника:\t");
scanf("%s",man[i].surname);
printf("Должность сотрудника:\t");
scanf("%s",man[i].titul);
printf("Зарплата:\t");
scanf("%d",&man[i].money);
}
}
void give_inform(struct stuff *man,int n)
{
printf("|Номер |Имя |Фамилия |Должность |Зарплата |\n");
for (int i=0; i<n; i++)
{
printf("|%-8d|%-15s|%-18s|%-15s|%-12d|\n",man[i].number,man[i].name,man[i].surname,man[i].titul,man[i].money);
}
}
void take_file(struct stuff*man,int n)
{
char icon[30];
printf("Как назвать файл таблицы?\n");
scanf("%s",icon);
FILE * why = fopen(icon, "w");
fprintf(why,"|Номер |Имя |Фамилия |Должность |Зарплата |\n");
for ( int i=0; i<n;i++)
{
fprintf(why,"|%-8d|%-15s|%-18s|%-15s|%-12d|\n",man[i].number,man[i].name,man[i].surname,man[i].titul,man[i].money);
}
fclose(why);
}
int main()
{
setlocale(LC_CTYPE,"rus");
int n;
printf(" Введите число сотрудников\n");
scanf("%d",&n);
struct stuff *man;
man = (struct stuff*)malloc(n*sizeof(struct stuff));
scan_inform(man,n);
give_inform(man,n);
take_file(man,n);
}
Соседние файлы в папке 1 практика