1)
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
| #include <iostream>
#include <cmath>
using namespace std;
const char* months[] = {
"January",
"Februare",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
const int days_in_month[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
void print_months(const char ** months, const int* days);
int main(){
print_months(months, days_in_month);
return 0;
}
void print_months(const char ** months, const int* days){
cout << "Table - days in months\n";
for (int i = 0; i < 12; i++)
{
cout << "In " << months[i] << " - " << days[i] << " days\n";
}
} |
|
Добавлено через 6 минут
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
| #include <iostream>
#include <cmath>
using namespace std;
typedef struct tagMonths {
const char *month;
int days;
} Months;
void print_months(const Months* m, const int n);
int main(){
const int n = 12;
Months months[n] = {
{"January", 31},
{"February", 28},
{"March", 31},
{"April", 30},
{"May", 31},
{"June", 30},
{"July", 31},
{"August", 31},
{"September", 30},
{"October", 31},
{"November", 30},
{"December", 31},
};
print_months(months, n);
return 0;
}
void print_months(const Months* m, const int n){
cout << "Table of months:\n";
for (int i = 0; i < n; i++)
{
cout << "In " << m[i].month << " - " << m[i].days << " days\n";
}
} |
|
3
|