-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiesiace_switch.cpp
More file actions
52 lines (42 loc) · 902 Bytes
/
miesiace_switch.cpp
File metadata and controls
52 lines (42 loc) · 902 Bytes
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
#include <iostream>
using namespace std;
int main ()
{
cout << "Podaj numer miesiaca: ";
int nr_miesiaca;
if (!(cin >> nr_miesiaca))
{
cerr << "To nie jest liczba!";
return 0;
}
switch (nr_miesiaca)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
cout << "Ten miesiac ma 31 dni!\n";
break;
case 4:
case 6:
case 9:
case 11:
cout << "Ten miesiac ma 30 dni!\n";
break;
case 2:
int rok;
cout << "Podaj rok: ";
cin >> rok;
if ((rok % 4 == 0 && rok % 100 != 0) || rok % 400 == 0)
cout << "Ten miesiac ma 29 dni!\n";
else
cout << "Ten miesiac ma 28 dni!\n";
break;
default:
cout << "Niepoprawny numer miesiaca!\n";
}
return 0;
}