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


+ Recent posts