forked from Salamander0/Progtest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogtest11:2.c
86 lines (78 loc) · 2.62 KB
/
progtest11:2.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PNUM 5
typedef struct pacient{
char prijmeni[50];
char jmeno[50];
int rodnec;
char nemoc[50];
char zp[50];
}TPacient;
int main(void)
{
TPacient pacient[PNUM];
char c;
for(int i=0; i<PNUM; i++){
printf("Zadejte prijmeni, jmeno, rodne cislo, nemoc a zdravotni pojistovnu pacienta:\n");
if(scanf("%s", pacient[i].prijmeni) != 1){
printf("Invaid input.\n");
return EXIT_FAILURE;
}
if((c =getc(stdin)) != ' '){
printf("Invaid input.\n");
return EXIT_FAILURE;
}
if(scanf("%s", pacient[i].jmeno) != 1){
printf("Invaid input.\n");
return EXIT_FAILURE;
}
if((c =getc(stdin)) != ' '){
printf("Invaid input.\n");
return EXIT_FAILURE;
}
if(scanf("%d", &pacient[i].rodnec) != 1){
printf("Invaid input.\n");
return EXIT_FAILURE;
}
if((c =getc(stdin)) != ' '){
printf("Invaid input.\n");
return EXIT_FAILURE;
}
if(scanf("%s", pacient[i].nemoc) != 1){
printf("Invaid input.\n");
return EXIT_FAILURE;
}
if((c =getc(stdin)) != ' '){
printf("Invaid input.\n");
return EXIT_FAILURE;
}
if(scanf("%s", pacient[i].zp) != 1){
printf("Invaid input.\n");
return EXIT_FAILURE;
}
}
for(int i=0; i<PNUM; i++){
if(strcmp(pacient[i].nemoc, "tbc") == 0)
printf("Jmeno a prijmeni pacienta s tbc:\n %s %s\n", pacient[i].jmeno, pacient[i].prijmeni);
if(strcmp(pacient[i].zp, "211") == 0)
printf("Jmeno a prijmeni pacientu s pojistovnou 211 je:\n %s %s\n", pacient[i].jmeno, pacient[i].prijmeni);
}
printf("Prijmeni vsech pacientu jsou:\n");
for(int i=0; i<PNUM; i++){
printf("%s\n", pacient[i].prijmeni);
}
return EXIT_SUCCESS;
}