Last active
January 30, 2023 08:25
-
-
Save Myoga1012/6c2f0fe3eb8cffe04538 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
// 名前 : Myoga Screw-bright (旧名:Myoga S. Tomonaka) | |
// Twitter : https://twitter.com/Myoga1012 | |
#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 Myoga-TN.net All Rights Reserved. | |
// 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