zoukankan      html  css  js  c++  java
  • C++primer plus第六版课后编程题答案7.6

    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);
    }


  • 相关阅读:
    【交互稿】sample
    【公开数据】网站
    【交互】规范
    【Flask】https
    【Flask】run with ssl /https
    需求模版
    低功耗蓝牙BLE外围模式(peripheral)-使用BLE作为服务端
    AIDL示例
    Android使用BLE(低功耗蓝牙,Bluetooth Low Energy)
    Android网络访问库
  • 原文地址:https://www.cnblogs.com/qq84435/p/3664887.html
Copyright © 2011-2022 走看看