본문 바로가기

문제 풀이11

기본 개념과 핵심 원리로 배우는 C++ 프로그래밍 10장 프로그래밍 문제 1. 다음 프로그램처럼 정수를 문자열로 바꾼 후 멤버 m_Str에 저장하는 클래스 CIntStr를 타입 변환 생성자를 이용하여 작성하시오.(단, C표준 라이브러리 함수인 _itoa를 사용한다.) #include #include using namespace std; class CIntToStr { public: CIntToStr(int arg) { m_Str = new char[20]; m_Str = _itoa(arg, m_Str, 10); } char* m_Str; ~CIntToStr() { delete m_Str; } }; void main() { CIntToStr s(1); cout 2023. 10. 31.
개념과 핵심원리로 배우는 C++ 프로그래밍 6장 프로그래밍 문제 1. 배열 int arr[] = {1,6,9,7,3,2,0,4,8,5}를 가지고 다음 프로그램을 작성하시오. (1) arr의 모든 원소의 합을 구하는 프로그램 (2) arr의 최솟값과 최댓값을 구하는 프로그램 (3) arr의 원소들을 역순으로 재구성하는 프로그램 (4) arr의 원소들을 오름파순으로 정렬하여 재구성하는 프로그램 #include using namespace std; void funcprint(int arg[], int arrLen); void funcsum(int arg[], int arrLen); void funcmaxmin(int arg[], int arrLen); void inversesort(int arg[], int arrLen); int main(void){ int arr[] =.. 2023. 10. 31.
개념과 핵심원리로 배우는 C++ 프로그래밍 5장 프로그래밍 문제 1. 다음 프로그래밍 출력 결과가 문자열"C++"가 되도록 Set 함수를 작성하시오. void main() { int a = 0; char* s = (char*)&a; Set(s); cout 2023. 10. 31.
개념과 핵심원리로 배우는 C++ 프로그래밍 4장 프로그래밍 문제 1. if~else를 이용하여 입력받은 정수의 짝/홀수 여부를 출력하는 프로그램을 작성하시오. #include using namespace std; int main(void){ int num; while(true){ cout > num; if(num == 0){ cout 2023. 10. 31.