Ещё один вариант. Написано и проверено на PascalABC. Далеко от идеала, зато свой код. :)
P.S.: внесены небольшие изменения.. .
Program Data;
Var
a,b,c,count,left:word;
label l1;
Begin
l1:
count:=0;
left:=0;
Write('Enter Day ');
Readln(a);
Write('Enter Month ');
Readln(b);
Write('Enter Year ');
Readln(c);
case a of
1..31:
if b >1 then
begin
count:=31;
if b>2 then count:=count+28;
if b>3 then count:=count+31;
if b>4 then count:=count+30;
if b>5 then count:=count+31;
if b>6 then count:=count+31;
if b>7 then count:=count+30;
if b>8 then count:=count+31;
if b>9 then count:=count+30;
if b>10 then count:=count+31;
if b>11 then count:=count+30;
if c mod 4=0 then
count:=count+a+1 else
count:=count+a;
if c mod 4=0 then
left:=366-count else
left:=365-count;
end else
begin
if c mod 4 = 0 then
begin
count:=a;
left:=366-count;
end else
begin
count:=a;
left:=365-count;
end;
end;
32..65535:
begin
Writeln('Wrong date');
goto l1;
end;
end;
case b of
2:if c mod 4>0 then if a>28 then
begin
writeln('Wrong date');
goto l1
end else
if a>29 then
begin
writeln('Wrong date');
goto l1;
end;
13..65535:
begin
writeln('Wrong month');
goto l1;
end;
4,6,9,11: if a>30 then
begin
writeln ('Wrong date');
goto l1;
end;
end;
Writeln('Day #'+inttostr(count));
Writeln('Days left: '+inttostr(left));
Readln;
End.
Другие языки программирования и технологии
Программисты! Помогите пожалуйста! Нужно на паскале написать код к следующей задаче: Даны натуральные числа a, b, c
program ttt;
var
a,b,c:integer;
begin
a:=3;
b:=4;
c:=5;
end.
var
a,b,c:integer;
begin
a:=3;
b:=4;
c:=5;
end.
Для TURBOPACSAL
program v748;
uses Graph,Crt;
var graphdriver,graphmode,a,b,c:integer;
z,m:real;
zs,ms:string;
ch:char;
n:boolean;r:char;
label strt;
begin
graphdriver:=detect;
initgraph(a,b,'egavga.bgi');
strt:setfillstyle(1,4);
setcolor(15);
settextstyle(2,0,6);
bar(150,100,490,300);
outtextxy(160,110,'Vvedite den`: ');
gotoxy(52,8);
readln(a);
outtextxy(160,126,'Vvedite mesyac: ');
gotoxy(52,9);
readln(b);
outtextxy(160,142,'Vvedite god: ');
gotoxy(52,10);
readln(c);
outtextxy(160,162,'Press Enter...');
readln;
n:=true;
if c<0 then n:=false;
if (b<=0) or (b>12) then n:=false;
if (b=1) or (b=3) or (b=5) or (b=7) or (b=8) or (b=10) or (b=12) then
if (a<=0) or (a>31) then n:=false;
if (b=4) or (b=6) or (b=9) or (b=11) then
if (a<=0) or (a>30) then n:=false;
if (b=2) and (c mod 4=0) then if (a<=0) or (a>29) then n:=false;
if (b=2) and (c mod 4<>0) then if (a<=0) or (a>28) then n:=false;
setfillstyle(1,1);
setcolor(10);
bar(150,100,490,300);
settextstyle(3,0,2);
if n then outtextxy(160,110,'Data verna') else outtextxy(160,110,'Data neverna');
z:=0;
if (b=1) then z:=a;
if (b=2) then z:=31+a;
if (b=3) then z:=59+a;
if (b=4) then z:=90+a;
if (b=5) then z:=120+a;
if (b=6) then z:=151+a;
if (b=7) then z:=181+a;
if (b=8) then z:=212+a;
if (b=9) then z:=243+a;
if (b=10) then z:=273+a;
if (b=11) then z:=304+a;
if (b=12) then z:=334+a;
m:=0;
m:=365-z-1;
str(z:3:0,zs);
str(m:3:0,ms);
outtextxy(160,126,'Proshlo dney: ');
outtextxy(160,134,zs);
outtextxy(160,142,'Ostalos` dney: ');
outtextxy(160,151,ms);
outtextxy(160,162,'Press Enter...');
readln;
setfillstyle(1,14);
setcolor(8);
bar(150,100,490,300);
outtextxy(240,190,'Povtorit` (y/n)');
repeat r:=readkey;
until (r='y') or (r='n');
if r='y' then goto strt;
closegraph;
end.
program v748;
uses Graph,Crt;
var graphdriver,graphmode,a,b,c:integer;
z,m:real;
zs,ms:string;
ch:char;
n:boolean;r:char;
label strt;
begin
graphdriver:=detect;
initgraph(a,b,'egavga.bgi');
strt:setfillstyle(1,4);
setcolor(15);
settextstyle(2,0,6);
bar(150,100,490,300);
outtextxy(160,110,'Vvedite den`: ');
gotoxy(52,8);
readln(a);
outtextxy(160,126,'Vvedite mesyac: ');
gotoxy(52,9);
readln(b);
outtextxy(160,142,'Vvedite god: ');
gotoxy(52,10);
readln(c);
outtextxy(160,162,'Press Enter...');
readln;
n:=true;
if c<0 then n:=false;
if (b<=0) or (b>12) then n:=false;
if (b=1) or (b=3) or (b=5) or (b=7) or (b=8) or (b=10) or (b=12) then
if (a<=0) or (a>31) then n:=false;
if (b=4) or (b=6) or (b=9) or (b=11) then
if (a<=0) or (a>30) then n:=false;
if (b=2) and (c mod 4=0) then if (a<=0) or (a>29) then n:=false;
if (b=2) and (c mod 4<>0) then if (a<=0) or (a>28) then n:=false;
setfillstyle(1,1);
setcolor(10);
bar(150,100,490,300);
settextstyle(3,0,2);
if n then outtextxy(160,110,'Data verna') else outtextxy(160,110,'Data neverna');
z:=0;
if (b=1) then z:=a;
if (b=2) then z:=31+a;
if (b=3) then z:=59+a;
if (b=4) then z:=90+a;
if (b=5) then z:=120+a;
if (b=6) then z:=151+a;
if (b=7) then z:=181+a;
if (b=8) then z:=212+a;
if (b=9) then z:=243+a;
if (b=10) then z:=273+a;
if (b=11) then z:=304+a;
if (b=12) then z:=334+a;
m:=0;
m:=365-z-1;
str(z:3:0,zs);
str(m:3:0,ms);
outtextxy(160,126,'Proshlo dney: ');
outtextxy(160,134,zs);
outtextxy(160,142,'Ostalos` dney: ');
outtextxy(160,151,ms);
outtextxy(160,162,'Press Enter...');
readln;
setfillstyle(1,14);
setcolor(8);
bar(150,100,490,300);
outtextxy(240,190,'Povtorit` (y/n)');
repeat r:=readkey;
until (r='y') or (r='n');
if r='y' then goto strt;
closegraph;
end.
g
Похожие вопросы
- помогите решить задачу!...Даны целые числа a, b, c, являющиеся сторонами некоторого треугольника.Проверить истинность вы
- 9. Даны натуральные числа A, B и C, обозначающие число, месяц и год. Проверить корректность этой даты. Выбрать оптимальн
- Найти трехзначные числа a, b, c, все цифры которых различны и удовлетворяют уравнению a^2 – b^2 – c^2 = a – b – c.
- даны 3 разл целых числа a,b,c используя оператор GOTO составить программу для ввода чисел в порядке убывания
- помогите составить таблицы истиности -А -> (B + C); (A B) * C; -A + -B + C; - (A + B) * C ; A * B _+ C; A B
- срочно помогите написать программу на ассемблере вычисляющую R. R=x2+y2, где x=a+b-c, y=b*c-a. a,b,c вводятся с клавы
- Pascal. Дан натуральный отрезок чисел [A,B]. Найти те числа этого отрезка, которые являются степенью двойки.
- {(a,b), (c,b), (c,a)} - является транзитивным или нет?
- Создать программу по турбопаскаль вывести ответ желтым цветом даны три A,B,C числа найти максимальное
- dev c++. помогите плз сделать задачу найти наибольшую высоту треугольника из сторонами a,b,c