program m1;
var a,b,c,:integer;
help:string;
begin
b:=0;
for var i:=2848 to 109499 do
str(i,help);
if pos('9',help)<>0 then
c := 0;
a:=i;
while a > 0 do
if a mod 10 > 5 then
c := c + a mod 10;
end;
a := a div 10;
if c mod 3 = 0 then
b:=b+1;
if pos('8',help)=1 then
writeln(i);
writeln(b);
end.
Объяснение:
20865 89997
В функции CheckDate() присутствует все необходимые проверки правильности введенной даты.
Код программы:
#include <iostream>
#include <locale>
using namespace std;
struct TDate{
int Day;
int Month;
int Year;
};
int CheckDate(TDate D) {
if (D.Month < 1 || D.Month > 12)
return 1;
if (D.Month % 2 == 1) {
if (D.Month < 8) {
if (D.Day < 1 || D.Day > 31)
return 2;
}
else {
if (D.Day < 1 || D.Day > 30)
else{
if (D.Month == 2) {
if (D.Year % 4 == 0) {
if (D.Day < 1 || D.Day > 29)
if (D.Day < 1 || D.Day > 28)
if (D.Month >= 8) {
return 0;
int main(void) {
TDate a = { 29, 2, 2035 },
b = { 29, 2, 2036 },
c = { 25, 12, 2056 },
d = { 31, 11, 2001 },
e = { 30, 4, 2004 },
g = { 2, 13, 2000 };
cout << CheckDate(a) << endl;
cout << CheckDate(b) << endl;
cout << CheckDate(c) << endl;
cout << CheckDate(d) << endl;
cout << CheckDate(e) << endl;
cout << CheckDate(g) << endl;
program m1;
var a,b,c,:integer;
help:string;
begin
b:=0;
for var i:=2848 to 109499 do
begin
str(i,help);
if pos('9',help)<>0 then
begin
c := 0;
a:=i;
while a > 0 do
begin
if a mod 10 > 5 then
begin
c := c + a mod 10;
end;
a := a div 10;
end;
if c mod 3 = 0 then
begin
b:=b+1;
if pos('8',help)=1 then
begin
writeln(i);
end;
end;
end;
end;
writeln(b);
end.
Объяснение:
20865 89997
В функции CheckDate() присутствует все необходимые проверки правильности введенной даты.
Код программы:
#include <iostream>
#include <locale>
using namespace std;
struct TDate{
int Day;
int Month;
int Year;
};
int CheckDate(TDate D) {
if (D.Month < 1 || D.Month > 12)
return 1;
if (D.Month % 2 == 1) {
if (D.Month < 8) {
if (D.Day < 1 || D.Day > 31)
return 2;
}
else {
if (D.Day < 1 || D.Day > 30)
return 2;
}
}
else{
if (D.Month == 2) {
if (D.Year % 4 == 0) {
if (D.Day < 1 || D.Day > 29)
return 2;
}
else {
if (D.Day < 1 || D.Day > 28)
return 2;
}
}
else {
if (D.Month >= 8) {
if (D.Day < 1 || D.Day > 31)
return 2;
}
else {
if (D.Day < 1 || D.Day > 30)
return 2;
}
}
}
return 0;
}
int main(void) {
TDate a = { 29, 2, 2035 },
b = { 29, 2, 2036 },
c = { 25, 12, 2056 },
d = { 31, 11, 2001 },
e = { 30, 4, 2004 },
g = { 2, 13, 2000 };
cout << CheckDate(a) << endl;
cout << CheckDate(b) << endl;
cout << CheckDate(c) << endl;
cout << CheckDate(d) << endl;
cout << CheckDate(e) << endl;
cout << CheckDate(g) << endl;
}