๐Ÿงฉ Algorithm/[BOJ] Bronze

BOJ 10699๋ฒˆ : ์˜ค๋Š˜ ๋‚ ์งœ (C++/Bronze 5)

devCloud 2022. 8. 4. 15:23
728x90
 

10699๋ฒˆ: ์˜ค๋Š˜ ๋‚ ์งœ

์„œ์šธ์˜ ์˜ค๋Š˜ ๋‚ ์งœ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

www.acmicpc.net

๋ฌธ์ œ

์„œ์šธ์˜ ์˜ค๋Š˜ ๋‚ ์งœ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

 

์ถœ๋ ฅ

์„œ์šธ์˜ ์˜ค๋Š˜ ๋‚ ์งœ๋ฅผ "YYYY-MM-DD" ํ˜•์‹์œผ๋กœ ์ถœ๋ ฅํ•œ๋‹ค.


์˜ˆ์ œ ์ถœ๋ ฅ

2015-01-24

Solution

#include <iostream>

int main(){
    std::cout << "2022-08-04";
    return 0;
}

์ถ”๊ฐ€๋กœ, ๋ฌธ์ž์—ด๋งŒ ์ž…๋ ฅํ•˜๋Š” ๊ฒƒ์ด ํ˜„์žฌ ๋‚ ์งœ์™€ ํ˜„์žฌ ์‹œ๊ฐ„์„ ์ถœ๋ ฅํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ์ฝ”๋“œ๋‹ค.

#include <iostream>
#include <ctime>
#include <string>
#include <stdio.h>

const std::string currentDateTime() {
    time_t     now = time(0);
    struct tm  tstruct;
    char       buf[80];
    tstruct = *localtime(&now);
    strftime(buf, sizeof(buf), "%Y-%m-%d",&tstruct);
    return buf;
}

int main() {
    std::cout << currentDateTime();
}
728x90