본문 바로가기

개념과 핵심원리로 배우는 C++ 프로그래밍6

개념과 핵심원리로 배우는 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.
개념과 핵심원리로 배우는 C++ 프로그래밍 3장 프로그래밍 문제 1. 삼항 연산자를 이용하여 입력받은 정수의 짝수, 홀수 여부를 출력하는 프로그램을 작성하시오. #include #include using namespace std; string evenodd(int num){ string even = "짝수"; string odd = "홀수"; return num % 2 == 0 ? even : odd; } int main (void){ int num; while(true){ cout > num; if(num == 0){ cout 2023. 10. 31.