有代码看不懂
程序代码:
#include <iostream> #define SIZE 5 using namespace std; void show_array(const double ar[], int n); void mult_array(double ar[], int n, double mult); int main() { double dip[SIZE] = {20.0, 17.66, 8.2, 15.3, 22.22}; cout << "The original dip array:\n"; show_array(dip, SIZE); mult_array(dip, SIZE, 2.5); cout << "The dip array after calling mult_array():\n"; show_array(dip, SIZE); return 0; } void show_array(const double ar[], int n) { int i; for (i = 0; i < n; i++) cout << ar[i]; cout << endl; } void mult_array(double ar[], int n, double mult) { int i; for (i = 0; i < n; i++) ar[i] *= mult; }
这两段的结果怎么算呢??
show_array(dip, SIZE); mult_array(dip, SIZE, 2.5);
为什么输出的结果是
The original dip array: 2017.668.215.322.22 The dip array after calling mult_array(): 5044.1520.538.2555.55
谢谢大佬!!!