0 / 0 / 0
Регистрация: 10.01.2017
Сообщений: 11
|
|
1
|
Блок-схема к коду
23.02.2018, 01:57. Показов 925. Ответов 1
Доброго времени суток!
Помогите создать блок-схему по коду
Файл Worker.h:
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| #include <time.h>
class Worker
{
public:
Worker();
Worker(char name[100], char number[9], char department[100], char post[100], int day, int month, int year);
~Worker();
void print();
tm experience();
private:
char name[100];
char number[9];
char department[100];
char post[100];
int day;
int month;
int year;
}; |
|
Файл Worker.cpp:
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
| #define _CRT_SECURE_NO_WARNINGS
#include "Worker.h"
#include <iostream>
using namespace std;
Worker::Worker()
{
strcpy(name, "");
strcpy(number, "00000000");
strcpy(department, "");
strcpy(post, "");
day = 0;
month = 0;
year = 0;
}
Worker::Worker(char name[100], char number[9], char department[100], char post[100], int day, int month, int year)
{
strcpy(this->name, name);
strcpy(this->number, number);
strcpy(this->department, department);
strcpy(this->post, post);
this->day = day;
this->month = month;
this->year = year;
}
Worker::~Worker() {}
void Worker::print()
{
cout << "ФИО: " << name;
cout << "\nТабельный номер: " << number;
cout << "\nОтдел: " << department;
cout << "\nДолжность: " << post;
cout << "\nДата принятия: ";
printf("\nДата принятия: %02d.%02d.%04d", day, month, year);
if (strlen(name) != 0) {
tm exp = experience();
cout << "\nОпыт работы:";
cout << "\n Дней: " << exp.tm_mday;
cout << "\n Месяцев: " << exp.tm_mon;
cout << "\n Лет: " << exp.tm_year;
}
}
tm Worker::experience()
{
time_t t = time(NULL);
tm *current = localtime(&t);
int cDay = current->tm_mday;
int cMonth = current->tm_mon + 1;
int cYear = current->tm_year + 1900;
tm exp;
if (cDay >= day) exp.tm_mday = cDay - day;
else {
cMonth -= 1;
exp.tm_mday = cDay + 31 - day;
}
if (cMonth >= month) exp.tm_mon = cMonth - month;
else {
cYear -= 1;
exp.tm_mon = cMonth + 12 - month;
}
if (cYear >= year) exp.tm_year = cYear - year;
else exp.tm_year = 0;
return exp;
} |
|
Файл main.cpp:
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <conio.h>
#include "Worker.h"
using namespace std;
void main()
{
setlocale(0, "Russian");
char name[100], number[9], department[100], post[100];
int day, month, year;
cout << "Введите информацию о работнике.";
cout << "\nФИО: ";
scanf("%100s", name);
cout << "Табельный номер (8 символов): ";
scanf("%8s", number);
cout << "Отдел: ";
scanf("%100s", department);
cout << "Должность: ";
scanf("%100s", post);
cout << "День принятия: ";
cin >> day;
cout << "Номер месяца принятия: ";
cin >> month;
cout << "Год принятия: ";
cin >> year;
cout << endl;
Worker aiDeveloper(name, number, department, post, day, month, year);
aiDeveloper.print();
cout << endl << endl;
cout << "Worker с пустым конструктором:\n\n";
Worker none;
none.print();
_getch();
} |
|
0
|