using System;
class xCalendar
{
public long 서기_1_1_1부터_지난해_마지막날까지의_날수(long year)
{
long lastYear = year - 1;
long total;
//년도 * 365일
total = lastYear * 365;
//윤년의 수를 더함(4로나누어 떨어지면 일단 윤년)
total = total + (lastYear / 4);
//100으로 나누어 떨어지면 평년
total = total - (lastYear / 100);
//100으로 나누어 떨어지면 다시 윤년
total = total + (lastYear / 400);
return total;
}
////////////////////////////////////////////
//주어진 year가 윤년이면 1을 return, 평년이면 0을 return하는 함수
public long yoonYear(long year)
{
if ((year % 400) == 0) return 1;
if ((year % 100) == 0) return 0;
if ((year % 4) == 0) return 1;
return 0;
}
////////////////////////////////////////////
public long 올해_1_1부터_지난달_마지막날까지의_날수(long year, long month)
{
long[] numDays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
//C++ -> long numDays[12] /// C# -> long[] numDays
numDays[1] = numDays[1] + yoonYear(year);
long total = 0;
long lastMonth = month - 1;
for (long i = 0; i < lastMonth; i = i + 1)
{
total = total + numDays[i];
}
return total;
}
/////////////////////////////////////////
public long 서기_1년_1월_1일부터_year_month_date까지의_날수(long year, long month, long date)
{
long total;
total = 서기_1_1_1부터_지난해_마지막날까지의_날수(year) +
올해_1_1부터_지난달_마지막날까지의_날수(year, month) +
date;
return total;
}
/////////////////////////////////////////
public long weekDay(long year, long month, long date)
{
long total = 서기_1년_1월_1일부터_year_month_date까지의_날수(year, month, date);
return (total % 7);
}
////////////////////////////////////////
public void calendar(int year, int month)
{
//이 아래에 아래와 같이 달력을 출력하는 명령어를 코딩하시오.
/*2012년 5월
============================
일 월 화 수 목 금 토
============================
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
*/
Console.WriteLine(" %d년 %d월\n", year, month);
Console.WriteLine("=====================\n");
Console.WriteLine(" 일 월 화 수 목 금 토\n");
Console.WriteLine("=====================\n");
Console.WriteLine(" 1 2 3 4 5\n");
int a, b;
int c = 6;
//for(a=0; a<=weekDay(year,month,1); a++)
// printf(" ");
//for(a=1; a<=weekDay(year,month,31); a++)
// printf("%3d", a);
for (a = 1; a < 5; a++)
{
for (b = 1; b <= 7; b++)
{
if (a == 5 && b < 8)
Console.WriteLine(" ");
else if (year == 2012 && month == 5)
{
Console.WriteLine(" %2d", c);
c++;
if (c > 31)
{
Console.WriteLine("\n");
break;
}
}
}
Console.WriteLine("\n");
}
}
}
class Program
{
static void Main()
{
// xCalendar의 객체를 생성한다 = cal
xCalendar cal = new xCalendar();
//Console.WriteLine("요일 : " + cal.weekDay(2012, 4, 4)); 위의 코드와 같은값
}
}
이렇게 대충 짯는데 이거 Program이라는 클래스에서 위에함수 불러다가 출력해야하는데
어떻게 써야 위에껄 불러서 출력을 하는거야....????
C#책도 없고 수업도 없는데 C언어 수업에서 이딴거 내줘서 미칠거 같아 형들 제발 알려줘 ㅠㅠ
글설리1
글설리2
글설리3
글설리4
글설리5
글설리6
글설리7
글설리8
글설리9
보는내가다설레였네 [핡]
조조 조조조조 조조 조조조조 조조 조조조조조