본문 바로가기

c++6

기본 개념과 핵심 원리로 배우는 C++ 프로그래밍 9장 프로그래밍 문제 1.다음 로봇 명세를 보고 프로그램을 작성하시오. 이름 신장(m) 무게(T) 마력 태권브이 18 80 3000 마징가 17 70 2500 메칸더브이 20 90 3500 그랜다이져 22 100 5000 (1) 로봇을 나타내는 클래스 CRobot을 설계하시오. 명세를 입력할 수 있는 멤버 함수 Set과 명세를 출력하는 멤버 함수 Print가 있다. (2)클래스 CRobot을 이용하여 모든 로봇의 명세를 출력하는 프로그램을 작성하시오. #include #include using namespace std; int cnt = 0; class CRobot{ public: int m_height[4],m_weight[4],m_power[4]; void set(int x, int y, int z){ m_height[c.. 2023. 10. 31.
기본 개념과 핵심 원리로 배우는 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.