ソースは短いから直接載せちゃう。
#include "puzutl.h"
int idays[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int main( int argc, cstring argv[])
{
int first = 0, last = 0, cnt = 0, maxFirst, maxLast, cntMax = 0;
char buf[10];
for( int m=1; m<= 12; m++) {
for( int d=1; d <= idays[m]; d++) {
sprintf( buf, "%d%d", m, d);
YesNo ynOK = YES;
cstring s = buf; while(*s) if(*s++=='0') ynOK=NO;
if( ynOK) {
if( first == 0) first = m*100 + d;
last = m*100 + d;
cnt++;
if( cnt > cntMax) { maxFirst = first; maxLast = last; cntMax = cnt;}
}
else {
first = 0;
cnt = 0;
}
}
}
ps( "%d月%d日〜%d月%d日まで%d日間\n", maxFirst/100, maxFirst%100, maxLast/100, maxLast%100, cntMax);
return 0;
}
プログラムの実行結果は以下の通り。
2月21日〜3月9日まで18日間