c++ Array的使用方法

直接上代码:

代码:


# include 
# include 
# include 
/*
    时间:2016年4月8日00:05:50
    内容:Array的使用方法
*/
const int Seasons=4;
const std::array<std::string,Seasons> Snames={"Spring","Summer","Fall","Winter"};
void fill(std::array<double,Seasons> *pa);
void show(std::array<double ,Seasons> da);
int main()
{
    std::array<double ,Seasons> expenses;
    fill(&expenses);
    show(expenses);
    return 0;
}

void fill(std::array<double,Seasons> *pa)
{
    using namespace std;
    for (int i=0;icout<<"Enter "<" expenses:";
        cin>>(*pa)[i];
    }
}
void show(std::array<double ,Seasons> da)
{
    using namespace std;
    double total=0.0;
    cout<<"\nEXPENSES\n";
    for (int i=0;icout<" : $"<cout<<"Total Expenses: $"</*
在Code::Block中的运行结果:
Enter Spring expenses:245
Enter Summer expenses:266
Enter Fall expenses:320
Enter Winter expenses:666

EXPENSES
Spring : $245
Summer : $266
Fall : $320
Winter : $666
Total Expenses: $1497

Process returned 0 (0x0)   execution time : 8.344 s
Press any key to continue.
*/

你可能感兴趣的:(C++)