1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <iostream> using namespace std; class ArrayUtility { public: static void intToDouble(int source[], double dest[], int size); static void doubleToInt(double source[], int dest[], int size); }; void ArrayUtility::intToDouble(int source[], double dest[], int size) { for (int i = 0; i < size; i++) { dest[i] = (double)source[i]; } } void ArrayUtility::doubleToInt(double source[], int dest[], int size) { for (int i = 0; i < size; 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::doubleToInt(z, x, 5); for (int i = 0; i < 5; i++) cout << x[i] << ' '; cout << endl; } | cs |
'Programming > 명품 C++ Programming' 카테고리의 다른 글
| 명품 C++ Programming 실습문제 6장 7번 (0) | 2018.05.26 |
|---|---|
| 명품 C++ Programming 실습문제 6장 6번 (0) | 2018.05.26 |
| 명품 C++ Programming 실습문제 6장 4번 (0) | 2018.05.10 |
| 명품 C++ Programming 실습문제 6장 3번 (0) | 2018.05.10 |
| 명품 C++ Programming 실습문제 6장 2번 (0) | 2018.05.10 |