当前位置:首页 > C++PrimerPlus第六版课后题第七章
cout<<\<< size < Show_array(ps, num); Reverse_array(ps, num); Show_array(ps, num); Reverse_array(ps + 1, num - 2); Show_array(ps, num); deleteps; return 0; } intFill_array(double *arr, int n) { inti = 0; cout<<\ ; while ( (i< n) && (cin>>arr[i])) i++; returni; } voidShow_array(double *arr, int n) { cout<<\< cout<<\< double * Reverse_array(double *arr, int n) { double * temp= newdouble [n]; for (inti = 0; i< n; i++) temp[i] = arr[n-i-1]; for (inti = 0; i< n; i++) arr[i] = temp[i]; delete temp; returnarr; } 7. #include 9 usingnamespacestd; constint Max = 5; double * Fill_array(doublear[], int limit); voidShow_array(constdoublear[], double * n); void revalue(double r, doublear[], double * n); int main() { double properties[Max]; double * address = Fill_array(properties, Max); Show_array(properties, address); if ((address - properties) > 0 ) { cout<<\ ; double factor; while (!(cin>> factor)) { cin.clear(); while (cin.get() != '\\n') continue; cout<<\ ; } revalue(factor, properties, address); Show_array(properties, address); } cout<<\< double * Fill_array(doublear[], int limit) { double temp; inti; for (i = 0; i< limit; i++) { cout<<\<> temp; if (!cin) { 10 cin.clear(); while (cin.get() != '\\n') continue; cout<<\ ; break; } elseif (temp < 0) break; ar[i] = temp; } return (ar + i); } voidShow_array(constdoublear[], double * n) { for (inti = 0; i< (n - ar); i++) cout<<\< void revalue(double r, doublear[], double * n) { for (inti = 0; i< (n - ar); i++) ar[i] *= r; } 8. a) #include usingnamespacestd; constint seasons = 4; constchar * arr[4] = {\, \, \, \}; voidfill(double * pa, int n); voidshow(constdouble * pa, int n); intmain() { doublear[seasons]; fill(ar, seasons); show(ar, seasons); return 0; } 11 voidfill(double * pa, int n) { for(inti= 0; i< n; i++) { cout<<\< voidshow(constdouble * pa, int n) { double total = 0.0; cout<<\; for(inti = 0; i< n; i++) { cout< cout<<\<< total < b) #include usingnamespacestd; constint seasons = 4; constchar * arr[4] = {\, \, \, struct money { double expense; }; voidfill(money * pa, int n); voidshow(const money * pa, int n); intmain() { money ar[seasons]; fill(ar, seasons); show(ar, seasons); return 0; 12 \};
共分享92篇相关文档