Add tags

Add tags to the following comment
ツェラーの公式を変形して。「今日の日付」はコマンドライン引数でもらいます。

$ ./fri13 2008 8 7
'09年2月13日
'09年3月13日
'09年11月13日
'10年8月13日
'11年5月13日
'12年1月13日
'12年4月13日
'12年7月13日
'13年9月13日
'13年12月13日
総数:10個
$
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <stdlib.h>

int main(int c, char *v[]) {
  int n = 0, y, m, y0 = atoi(v[1])-2000, m0 = atoi(v[2]);
  if (m0 < 3) { y0--; m0 += 12; }
  for (y = y0; y < 14; y++)
    for (m = 3; m < 15; m++) {
      if (y == y0 && (m < m0 || (m == m0 && atoi(v[3]) > 13))) continue;
      if (!((26*(m+1)/10+y+y/4)%7)) {
        printf("'%02d年%d月13日\n", (m>=13)?y+1:y, (m>=13)?m-12:m);
        n++;
      }
    }
  printf("総数:%d個\n", n);

  return 0;
}

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...