C++ 4

[백준 17478] c++ - cout 대신 printf문 사용 / c_str()

속도 문제때문에 #include scanf, printf문을 사용하고 있었는데 이번 문제에서는 오히려 printf문을 쓰니까 더 헷갈렸다.string str은 c++의 string 형태이기 때문에 printf문(C함수)에서는 c_str()를 이용해서 출력할 수 있다.//백준 17478 - 재귀함수가 뭔가요?#include #include using namespace std;void recur(int n, string str){ printf("%s\"재귀함수가 뭔가요?\"\n", str.c_str()); if(n == 0){ printf("%s\"재귀함수는 자기 자신을 호출하는 함수라네\"\n", str.c_str()); printf("%s라고 답변하였지.\n", str.c_str()); ..

Algorithm/Baekjoon 2024.07.15
728x90