年間カレンダー
Posted feedbacks - Other
前にも後ろにもはみ出しています。「年間」カレンダーとはよべないかも しれません。4クールカレンダーかな。 もうすこしカレンダーらしくなるように考えてみます。
InstallShield Scriptで書いてみました。
InstallShield Scriptは Windowsアプリケーション用のインストーラーを作成するための
言語です。
インストーラーを実行すると、年を入力するダイアログが表示されます。西暦を入力して
[次へ]ボタンを押すと、ダイアログに以下の形式でカレンダーが表示されます。
e.g.
2008/ 1
日 月 火 水 木 金 土
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
(中略)
2008/12
日 月 火 水 木 金 土
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
# InstallShield Profesional 7.01でビルドし、動作することを確認。
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #include "ifx.h"
prototype CreateCalendar(BYREF LIST, NUMBER, NUMBER);
prototype GetDayOfWeek(NUMBER, NUMBER, NUMBER);
prototype GetEndOfMonth(NUMBER, NUMBER);
prototype IsLeapYear(NUMBER);
LIST l;
NUMBER m, y;
STRING s;
program
AskText("年を入力してください。(1-9999)", "", s);
if (StrToNum(y, s) < ISERR_SUCCESS) then abort; endif;
if (y < 1 || y > 9999) then abort; endif;
l = ListCreate(STRINGLIST);
if (l = LIST_NULL) then abort; endif;
for m = 1 to 12
CreateCalendar(l, y, m);
endfor;
SdShowInfoList("", "", l);
ListDestroy(l);
abort;
endprogram
function CreateCalendar(l, y, m)
NUMBER d, i, w;
STRING s, t;
begin
w = GetDayOfWeek(y, m, 1);
d = GetEndOfMonth(y, m);
NumToStr(s, y); t = s;
NumToStr(s, m); if (StrLength(s) = 1) then s = " " + s; endif;
ListAddString(l, t + "/" + s, AFTER); t = "";
ListAddString(l, "日 月 火 水 木 金 土", AFTER);
for i = 1 to w
t = t + " ";
endfor;
for i = 1 to d
NumToStr(s, i);
if (StrLength(s) = 1) then t = t + " " + s; else t = t + s; endif;
if (GetDayOfWeek(y, m, i) = 6 || i = d) then
ListAddString(l, t, AFTER); t = "";
else
t = t + " ";
endif;
endfor;
ListAddString(l, "", AFTER);
end;
function GetDayOfWeek(y, m, d)
begin
if (m <= 2) then y = y - 1; m = m + 12; endif;
return (5 * y / 4 - y / 100 + y / 400 + (26 * m + 16) / 10 + d) % 7;
end;
function GetEndOfMonth(y, m)
begin
switch (m)
case 1, 3, 5, 7, 8, 10, 12 : return 31;
case 2 : if (IsLeapYear(y)) then return 29; else return 28; endif;
case 4, 6, 9, 11 : return 30;
endswitch;
end;
function IsLeapYear(y)
begin
if (y % 400 = 0) then return 1; endif;
if (y % 100 = 0) then return 0; endif;
if (y % 4 = 0) then return 1; endif;
return 0;
end;
|





186
#4884()
Rating4/4=1.00
nを入力としてn年の年間カレンダーを返すプログラムを作ってください 少なくとも日曜日と土曜日が判別出来るようにしてください 出力は標準出力でもファイルでも構いません デザインは各自のお好みで 出力例1: (y-calendar 2008)=> #=Saturday, @=Sunday 2008/1 1 2 3 4 #5 @6 7 ... 2008/2 1 #2 @3 4 5 6 7 ... ... 2008/12 1 2 3 4 5 #6 @7 ... 出力例2: (y-calendar 2008)=> M T W T F S S M 2008/ 1 1 2 3 4 5 6 7 ... 2008/ 2 1 2 3 4 ... ... 2008/12 1 2 3 4 5 6 7 8 ... 出力例3: (y-calendar 2008)は2008.htmlを出力する 2008.htmlの中身 ---- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>2008 calendar</title> <style type="text/css"> * {font-family: monospace;} span {margin: 0px 3px;} span.sunday {color:red;font-weight:bold;} span.saturday {color:blue;font-weight:bold;} dd ul li{display:inline;} </style> </head> <body> <h1>2008 calendar</h1> <dl> <dt>2008/1</dt> <dd><ul> <li><span class="weekday">1</span></li> <li><span class="weekday">2</span></li> <li><span class="weekday">3</span></li> <li><span class="weekday">4</span></li> <li><span class="saturday">5</span></li> <li><span class="sunday">6</span></li> ... </ul></dd> ... </dl> </body> </html> ----[ reply ]