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
|
#include <iostream>
using namespace std;
void calcVolts(double* current, double* resistance, double* voltage, const int size)
{
for (int i = 0; i < size; i++) {
voltage[i] = current[i] * resistance[i];
}
return;
}
int main() {
const int limit = 10;
double current[limit] = {10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, 3.98};
double resistance[limit] = {4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9, 4.8};
double voltage[limit] = {0};
calcVolts(current, resistance, voltage, limit);
for (int i = 0; i < limit; i++) {
cout << current[i] << '\t' << resistance[i] << '\t' << voltage[i] << endl;
}
return 0;
}
|