C++ primer plus第六版课后编程题答案7.8a


 

7.8a

 

#include <iostream>
using namespace std;

const int Seasons=4;
const char *season[Seasons]={"Spring","Summer","Fall","Winter"};

void fill(double *expenses);
void show(const double *);
void main78a()
{
	double expenses[Seasons];
	fill(expenses);
	show(expenses);
	system("pause");

}
void fill(double *expenses)
{
	for(int i=0;i<Seasons;i++)
	{
		cout<<"\nEnter  "<<*(season+i)<<" expenses:";
		cin>>*(expenses+i);
	}
	cout<<"Enter end!";

}
void show(const double *arr)
{
	cout<<"\nshow start!"<<endl;
	for(int i=0;i<Seasons;i++)
	{
		cout<<"The "<<*(season+i)<<" expenses is "<<*(arr+i)<<endl;
	
	}
	cout<<"show endl"<<endl;
}

 

 


发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注