Skip to content

Instantly share code, notes, and snippets.

@donguri9
Last active November 1, 2017 20:46
Show Gist options
  • Save donguri9/eab72eaf369eb6bd06143d48f3bb1382 to your computer and use it in GitHub Desktop.
Save donguri9/eab72eaf369eb6bd06143d48f3bb1382 to your computer and use it in GitHub Desktop.
カレンダー作成
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