package calendar;



import java.util.Calendar;

import java.util.Scanner;



public class Program {



	public static void main(String[] args) 

	{

		int []days = new int [42];

		

		

		

		Scanner scan = new Scanner(System.in);

		Calendar cal = Calendar.getInstance();

		while(true)

		{

			

			//현재 연,월,일

			int curYear = cal.get(Calendar.YEAR);

			int curMonth = cal.get(Calendar.MONTH)+1; //0부터시작

			int curDay = cal.get(Calendar.DATE);

			

			

			

			cal.set(curYear,curMonth-1,1); //몇월의 1일에 해당하는 요일 구하기

			int week = cal.get(Calendar.DAY_OF_WEEK);

			int start = 2-week;

			int end = cal.getActualMaximum(Calendar.DAY_OF_MONTH);

			

		

			for(int i=0,n=start; i<42; i++,n++)

				if(1<=n && n<=end)

					days[i]= n;

				else

					days[i]=0;

			

			

			System.out.printf("<%d년 %d월 달력입니다>\n\n",curYear, curMonth);

			System.out.printf("***%d일이 마지막 날 입니다***\n\n", end);

			for(int i=0, n=1; i<42; i++, n++)

			{

				System.out.printf("%2d\t",days[i]);

				if(n%7==0)

					System.out.printf("\n");

			}



			System.out.printf("년도와 월을 입력하세요 : \n");

			curYear=scan.nextInt();

			curMonth=scan.nextInt();

		}

		

		

	}

	

}


package calendar;



import java.util.Calendar;



public class Program {



	public static void main(String[] args) 

	{

		int []days = new int [42];

		

		

		Calendar cal = Calendar.getInstance();

		

		cal.set(2013,10-1,1); //10-1 = 10월 (0부터시작)

		int week = cal.get(Calendar.DAY_OF_WEEK);

		

		for(int i=0; i<31; i++)

			days[i+week-1]= i+1;

		

		

		

		System.out.printf("%d\n\n",week);

		

		for(int i=0, n=1; i<42; i++, n++)

		{

			System.out.printf("%2d\t",days[i]);

			if(n%7==0)

				System.out.println();

		}

		

				

		

	}

	

}



package array;

import java.util.Random;

public class my {

	public static void main(String[] args) {

		Random rand = new Random();

		int[] lotto = new int[6];

		int i, j, t;

		for (i = 0; i < 6; i++)

		{

			lotto[i] = rand.nextInt(45) + 1;

			System.out.printf("%d\t", lotto[i]);

		}

		System.out.println();

		for (i = 0; i < 5; i++)

		{

			t = lotto[i];

			lotto[i] = lotto[i + 1];

			lotto[i + 1] = t;

			for (j = 0; j < 6; j++)

				System.out.printf("%d\t", lotto[j]);

			System.out.println();

		}

	}

}

1~45 랜덤수 출력 후 

 1,2자리 2,3 자리 3,4자리 4,5자리 5,6자리 변경 
 각 과정 값 출력

 

 


package array;



import java.util.Random;



public class my

{

	public static void main(String[] args)

	{

		

		Random rand = new Random();

	

		int[] lotto = new int[6];

		int i,j,t;

				

		

		//1~45 랜덤수 발생시켜서 저장

		for(i=0 ; i<6 ; i++)

		{

			lotto[i] = rand.nextInt(45)+1;

			System.out.printf("%d\t", lotto[i]);

		}	

		

		System.out.println();



		

		//다음수와 크기비교 후 자리변경, 각자리수 반복

		for(j=0; j<5; j++)

			for(i=0; i<5; i++)

			if(lotto[i]>lotto[i+1])

			{

				t=lotto[i];

				lotto[i]=lotto[i+1];

				lotto[i+1]=t;

			}

		//결과값 출력

				for(j=0; j<6; j++)

					System.out.printf("%d\t", lotto[j]);

				System.out.println();

			}

	}

+ Recent posts