C++/문제풀이
-
[C++] 2차원 배열에서 최대, 최소값 구하기C++/문제풀이 2022. 6. 14. 19:41
실습 9-1 2차원 배열에서 최대, 최소값 구하기 [조건] const int ROW = 4, COL = 3; void printArray(int inumbers[][COL], int rowSize); int Min, Max; void findMinMax(int inumbers[][3], int rowSize); 최댓값, 최솟값을 저장하는 변수를 전역 변수로 지정 // // main.cpp // // Created by yeonsu on 2022/06/14. // // 2차원 배열에서 최대, 최소값 구하기(4행 3열) #include #include //rand 함수 #include const int ROW = 4, COL = 3; void printArray(int inumbers[][COL], int ..
-
[C++] ⭐️100개의 임의의 정수(0~0)발생시킨 후 숫자의 출현 빈도수 세기C++/문제풀이 2022. 6. 14. 15:31
실습 8-3번 문제 100개의 임의의 정수(0~0)발생시킨 후 숫자의 출현 빈도수 세기 void printArray(int inumbers[], int from, int to); void randomCounts(int count[], int size); int findMaxIndex(int count[], int size); void grapg(int count[], int size); 👆함수 이용 // // main.cpp // // Created by yeonsu on 2022/06/14. // // 100개의 임의의 정수(0~0)발생시킨 후 숫자의 출현 빈도수 세기 #include #include //rand 함수 #include using namespace std; void printArray(i..
-
[C++] 배열을 역순으로 만들기C++/문제풀이 2022. 6. 14. 14:37
실습 8-2 void reverse(int inumbers[], int size); [목표]함수를 이용하여 배열을 역순으로 만들기 // // main.cpp // // Created by yeonsu on 2022/06/14. // // 연도를 입력한 뒤 월별 일수 출력하기 #include #include //rand 함수 #include using namespace std; void printArray(int inumbers[], int from, int to); void reverse(int inumbers[], int size); int main(){ cout
-
[C++] 연도를 입력한 뒤 월별 일수 출력하기C++/문제풀이 2022. 6. 14. 14:23
실습문제 8-1 void printArray(int inumbers[], int from, int to); void daysInMonth(int year, int days[], int size); [목표] 함수와 배열을 이용하여 월별 일수 출력 // // main.cpp // // Created by yeonsu on 2022/06/14. // // 연도를 입력한 뒤 월별 일수 출력하기 #include #include //rand 함수 #include using namespace std; void printArray(int inumbers[], int from, int to); void daysInMonth(int year, int days[], int size); int main(){ cout > in..
-
[C++] 극장 좌석 예약 시스템(2차원 배열)C++/문제풀이 2022. 6. 13. 22:46
4 * 13 극장 좌석 예약 시스템 만들기 - 처음에는 전부 X로 초기화 - 좌석이 예약되면 배열 원소의 값이 O로 변경 // // main.cpp // // Created by yeonsu on 2022/06/13. // // 4 * 13 극장 좌석 예약 시스템 만들기 #include #include //rand 함수 #include using namespace std; void printArray(); char seats[4][13] = { {'X','X','X','X','X','X','X','X','X','X','X','X','X',}, {'X','X','X','X','X','X','X','X','X','X','X','X','X',}, {'X','X','X','X','X','X','X','X','X..
-
[C++] 2차원 배열을 이용하여 3개 학급 학생들의 평균 성적 구하기C++/문제풀이 2022. 6. 13. 20:34
power C++ 230p 2차원 배열을 이용하여 3개 학급 학생들의 평균 성적 구하기 [목표] 각 학급의 평균, 총 학생의 평균을 구한다. // // main.cpp // // Created by yeonsu on 2022/06/13. // // 3개 학급 학생들의 평균 성적 구하기 // [목표] // 각 학급의 평균, 총 학생의 평균을 구한다. #include #include //rand 함수 #include using namespace std; const int CLASSES = 3; const int STUDENTS = 5; int main(){ int array[CLASSES][STUDENTS] = { {1,2,3,4,5}, {6,7,8,9,10}, {11,12,13,14,15}, }; int ..
-
[C++] 2차원 배열 원소들의 합 구하기(난수 이용)C++/문제풀이 2022. 6. 13. 20:15
Power C++ p.229 2차원 배열 원소들의 합 구하기(난수 이용) // // main.cpp // // Created by yeonsu on 2022/06/13. // // 함수를 이용하여 2차원 배열의 원소들의 합 구하기 #include #include //rand 함수 #include using namespace std; //함수 원형 선언 int sum(int sum_array[][3]); int main(){ int array[3][3] = {0}; //2차원 배열 초기화 srand((unsigned)time(NULL)); //매번 새로운 난수 출력 //2차원 배열에 난수 집어넣기(이중 for문 활용) for(int i = 0; i
-
[C++] 배열과 포인터(*)를 이용하여 최대, 최소 구하기C++/문제풀이 2022. 5. 29. 21:57
[문제] C++ 200제 044번 배열과 포인터(*)를 이용하여 최대, 최소 구하기 - *를 인자로 사용하는 함수를 이용하여 최대, 최소를 구해보자. [기존 코드] // // main.cpp // // // Created by yeonsu on 2022/05/28. // #include #include #include using namespace std; int findMax(int x[], int n){ int max; max = x[0]; // 배열의 첫 번째 원소가 최댓값이라고 가정 for (int i = 0; i max) max = x[i]; } return max; } int findMin(int y[], int n){ int min; min = y[0]..