Last active
November 1, 2017 20:46
-
-
Save donguri9/eab72eaf369eb6bd06143d48f3bb1382 to your computer and use it in GitHub Desktop.
カレンダー作成
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
import Foundation | |
func printMonth(first fday:Int, days:Int){ | |
var d = 1 - fday | |
func daystr()->String{ | |
if d <= 0{ | |
return " " | |
}else{ | |
return (d < 10 ? " \(d)" : " \(d)") | |
} | |
} | |
while d <= days{ | |
var line = "" | |
for _ in 0..<7{ | |
line += daystr() | |
d += 1 | |
if d > days{break} | |
} | |
print(line) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment