
<code>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class ArrayUtility | |
{ | |
public: | |
ArrayUtility() {}; | |
~ArrayUtility() {}; | |
static void intToDouble(int source[], double dest[], int size) { | |
for (int i = 0; i < 5; i++) { | |
dest[i] = (double)source[i]; | |
} | |
} | |
static void doubleToDouble(double source[], int dest[], int size) { | |
for (int i = 0; i < 5; i++) { | |
dest[i] = (int)source[i]; | |
} | |
} | |
}; | |
int main() { | |
int x[] = { 1,2,3,4,5 }; | |
double y[5]; | |
double z[] = { 9.9,8.8,7.7,6.6,5.6 }; | |
ArrayUtility::intToDouble(x, y, 5); | |
for (int i = 0; i < 5; i++) cout << y[i] << ' '; | |
cout << endl; | |
ArrayUtility::doubleToDouble(z, x, 5); | |
for (int i = 0; i < 5; i++) cout << x[i] << ' '; | |
cout << endl; | |
} |
'C++ > 명품 c++ programming' 카테고리의 다른 글
명품 Programming C++ chapter 6 챕터 6장 실습 문제 4번 (0) | 2020.08.24 |
---|---|
명품 Programming C++ chapter 6 챕터 6장 실습 문제 3번 (0) | 2020.08.23 |
명품 Programming C++ chapter 6 챕터 6장 실습 문제 2번 (0) | 2020.08.23 |
명품 Programming C++ chapter 6 챕터 6장 실습 문제 1번 (0) | 2020.08.05 |
명품 Programming C++ chapter 5 챕터 5장 실습 문제 12번 (0) | 2020.08.04 |