-
-
Save Nia-TN1012/f6c5cfd8c7d5159849520881118314ff to your computer and use it in GitHub Desktop.
C++ / CLIでカレンダーを出力するソースコードです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 名前 : Nia Tomonaka | |
// Twitter : https://twitter.com/nia_tn1012 | |
#include "stdafx.h" | |
#include <stdio.h> | |
using namespace System; | |
int main( array<System::String ^> ^args ) { | |
// 現在の日付を取得します。 | |
DateTime ^now = DateTime::Today; | |
// 当月1日を表すインスタンスを生成します。 | |
DateTime ^day = gcnew DateTime( now->Year, now->Month, 1 ); | |
// 1日の位置をオフセットします。 | |
for( int i = 0; i < ( int )day->DayOfWeek; printf( " " ), i++ ); | |
do { | |
// 日付を出力します。 | |
printf( "%3d", day->Day ); | |
// dayが土曜日であれば、改行します。 | |
if( day->DayOfWeek == DayOfWeek::Saturday ) printf( "\n" ); | |
// dayを1日分進めて、月が変わるまで繰り返します。 | |
} while( ( day = day->AddDays( 1.0 ) )->Month == now->Month ); | |
if( day->DayOfWeek != DayOfWeek::Sunday ) printf( "\n" ); | |
return 0; | |
} | |
// Calender.cpp ( C++ / CLI ) | |
// Copyright (c) 2014-2023 Nia T.N. Tech Lab. / Chronoir.net. | |
// This software is released under the MIT License. | |
// http://opensource.org/licenses/mit-license.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GitHubのアカウント統合のため、Myoga1012→Nia-TN1012に移行しました。
旧URL: https://gist.github.com/Myoga1012/6c2f0fe3eb8cffe04538