ํฐ์คํ ๋ฆฌ ๋ทฐ
๋ฐ์ํ
์ ๊ทผ๋ฐฉ๋ฒ
1. ์ ๋ ฅํ ์๊น์ง์ ๋ชจ๋ ์ผ์๋ฅผ ๋ํ๋ค. (ex 3์ => 31+28+31)
2. ํด๋น ์์ ๋ง์ง๋ง ์ผ์ - ์ ๋ ฅํ ์ผ์ (ex 3์ 10์ผ => 31 - 10 )
3. ๋ชจ๋ ์ผ์ - (์ ๋ ฅ ์์ ๋ง์ง๋ง์ผ์ - ์ ๋ ฅ ์ผ์ ) = >totalDate
4. totalDate๋ฅผ 7๋ก ๋๋ ๋๋จธ์ง์ ๊ฐ์ ์์ผ๋ก ์ ์ (1=์, 2= ํ .... )
public static void main(String[] args) {
int[] months = {31,28,31,30,31,30,31,31,30,31,30,31};
char[] days = {'์','ํ','์','๋ชฉ','๊ธ','ํ ','์ผ'};
int totalDate = 0;
Scanner scanner = new Scanner(System.in);
int month = scanner.nextInt();
System.out.println(month);
int date = scanner.nextInt();
System.out.println(date);
for (int i = 0; i < month; i++) {
totalDate += months[i];
}
totalDate = totalDate-(months[month-1]-date);
System.out.println(month+"์ "+date+" ์ผ์ ์์ผ์ ? "+days[(totalDate%7)-1]);
}
๋ฐ์ํ
'โ Algorithm ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ ๋ฐฑ์ค ] 1065 ํ์ (0) | 2021.04.29 |
---|---|
[ ๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ 1152๋ฒ ] ๋จ์ด์ ๊ฐ์ (0) | 2019.10.29 |
[ ๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ 2941๋ฒ ] ํฌ๋ก์ํฐ์ ์ํ๋ฒณ (0) | 2019.10.28 |
๋๊ธ