7.6
#include <iostream> using namespace std; void Fill_array(double arr[],int arrSize) ;//因为是对数组进行操作,所以可以不用返回值; void const Show_array(const double arr[],int arrSize); void Reverse_array(double arr[],int arrSize); void main76() { double arr[10]; Fill_array(arr,10); Show_array(arr,10); Reverse_array(arr,10); system("pause"); } void Fill_array(double arr[],int arrSize) //因为是对数组进行操作,所以可以不用返回值; { int i=0;//用于记录输入了多少个数字 for(i=0;i<arrSize;i++) { cout<<" Please enter the "<<i+1<<" double values:"; if(!(cin>>arr[i]))//如果输入非法值,跳出循环 break; } cout<<" you had input "<<i<<" values!"<<endl; } void const Show_array(const double arr[],int arrSize) { cout<<"the array is:"<<endl; for(int i=0;i<arrSize&&arr[i]!=' ';i++) cout<<arr[i]<<" "; cout<<" show end!"<<endl; } void Reverse_array(double arr[],int arrSize) { int temp; cout<<" now Reverse the array!"<<endl; for(int i=1;i<arrSize/2;i++) { temp=arr[i]; arr[i]=arr[arrSize-1-i]; arr[arrSize-1-i]=temp; } cout<<"this is the new array:"<<endl; Show_array(arr,arrSize); }