Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {Chương trình tính thứ ngày tháng}
- program Hello;
- uses crt;
- const day = 1;
- const month = 2;
- const year = 3;
- const monday = 0;
- const tuesday = 1;
- const wednesday=2 ;
- const thursday = 3;
- const friday =4 ;
- const saturday = 5;
- const sunday = 6;
- type date = array[1..3] of Integer;
- type month_table = array[1..12] of Byte;
- var today : date;
- var input_date : date;
- var counter_date : date;
- var day_of_week : Integer;
- const days_of_months : month_table = (31, 28, 31, 30, 31, 30 , 31, 31, 30, 31, 30,31);
- procedure date_to_string(_date : date);
- begin
- Writeln(_date[day] ,'/' , _date[month] , '/' , _date[year]);
- end;
- function is_equal(date1 ,date2 : date) : boolean;
- var condition1, condition2, condition3 : boolean;
- begin
- condition1 := date1[day] = date2[day];
- condition2 := date1[month] = date2[month];
- condition3 := date1[year] = date2[year];
- is_equal := condition1 and condition2 and condition3;
- end;
- function increase(date : date) : date ;
- begin
- // leap year
- if((date[year] mod 4 = 0) and (date[year] mod 100 <> 0)) then
- days_of_months[2] := 29
- else
- days_of_months[2] := 28;
- date[day] := date[day] + 1;
- if(date[day] > days_of_months[date[month]]) then begin
- date[month] := date[month] + 1;
- // first day of next month
- date[day] := 1;
- end;
- if(date[month] > 12) then begin
- date[year] := date[year] + 1;
- // first month of a year;
- date[month]:= 1;
- end;
- increase := date;
- end;
- begin
- Clrscr;
- {16/9/2019}
- today[day] := 17; today[month] := 9; today[year] :=2019; day_of_week := tuesday;
- // Read Input
- Writeln('Ban hay nhap ngay = '); read(input_date[day]);
- Writeln('Ban hay nhap thang ='); Read(input_date[month]);
- Writeln('Ban hay nhap nam ='); Read(input_date[year]);
- counter_date := today;
- // while counter <= input;
- Readln;
- repeat
- counter_date := increase(counter_date);
- date_to_string(counter_date);
- day_of_week := day_of_week + 1;
- until is_equal(counter_date , input_date);
- day_of_week := day_of_week mod 7;
- case day_of_week of
- monday : WriteLn('Thu 2');
- tuesday : WriteLn('Thu 3');
- wednesday: WriteLn('Thu 4');
- thursday : WriteLn('Thu 5');
- friday : WriteLn('Thu 6');
- saturday : WriteLn('Thu 7');
- sunday : WriteLn('Chu nhat');
- end;
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement