一个可能的C++primer Plus第164页第6题的答案

来源:互联网 发布:百度大数据交响乐 编辑:程序博客网 时间:2024/05/01 09:59

一个可能的C++primer Plus第164页第6题的答案

//一个164/6.可能的答案//an possible answer of puzzle 6 of page 164#include<iostream>int main(){    using namespace std;    cout << "Please write down the sale number\n";    int i = 0;    int j = 0;    int sum = 0;//定义基本数 define the primer number    int NumberSaled[3][12];//定义一个二维数组来实现存储数据 define the array to store the number data    char* Month[12] = {        "January",        "February",        "March",        "April",        "May",        "Jane",        "July",        "August",        "September",        "October",        "November",        "December"    };    char* Nian[3]{        "The first year",        "The second year",        "The third year"    };//定义指向年月份名的指针数组 define an array of pointer to the name of year and month    for (; j < 3; j++) {        while (i < 12)        {            cout << "At the "<<Nian[j]<<"'s "<<Month[i] << " has the sale number of ";            cin >> NumberSaled[j][i];            sum += NumberSaled[j][i];            i++;        };        i = 0;    }    cout << "And we finally get the  fucing sum of them " << sum << endl;}
1 0