#include<iostream>#include<string>intmain(){usingnamespace std;
string months[12]={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};int sales[12];for(int i =0; i <12;++i){
cout <<"输入"<< months[i]<<"销售量: ";
cin >> sales[i];}int sum =0;for(int i =0; i <12;++i){
cout << months[i]<<": "<< sales[i]<< endl;
sum += sales[i];}
cout <<"今年销售量为: "<< sum << endl;return0;}
6.
intmain(){usingnamespace std;
string months[12]={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};int sales[3][12];for(int y =0; y <3;++y){
cout << endl;for(int m =0; m <12;++m){
cout <<"输入第"<< y+1<<"年"<< months[m]<<"销售量: ";
cin >> sales[y][m];}}int sum =0;for(int y =0; y <3;++y){
cout <<"第 "<< y <<"年: "<< endl;for(int m =0; m <12;++m){
cout << months[m]<<": "<< sales[y][m]<< endl;
sum += sales[y][m];}}
cout <<"今年销售量为:"<< sum << endl;return0;}
7.
#include<iostream>#include<string>struct Car {
std::string producer;int year;};intmain(){usingnamespace std;
cout <<"How many cars do you wish to catalog? ";int ncar;(cin >> ncar).get();
Car* cars =new Car[ncar];for(int i =0; i < ncar;++i){
cout <<"Car #"<< i +1<<":"<< endl;
cout <<"Please enter the make: ";getline(cin, cars[i].producer);
cout <<"Please enter the year made: ";
cin >> cars[i].year;
cin.get();}
cout <<"Here is your collection: "<< endl;for(int i =0; i < ncar;++i)
cout << cars[i].year <<" "<< cars[i].producer << endl;delete[] cars;return0;}
8.
#include<iostream>#include<cstring>constint StrLen =20;intmain(){usingnamespace std;char word[StrLen];
cout <<"Enter words (to stop, type the word done):"<< endl;int sum =0;
cin >> word;while(strcmp(word,"done")){
sum++;
cin >> word;}
cout <<"You entered a total of "<< sum <<" words."<< endl;return0;}
9.
#include<iostream>intmain(){usingnamespace std;
string word;
cout <<"Enter words (to stop, type the word done):"<< endl;int sum =0;
cin >> word;while(word !="done"){
sum++;
cin >> word;}
cout <<"You entered a total of "<< sum <<" words."<< endl;return0;}
10.
#include<iostream>intmain(){usingnamespace std;
cout <<"Enter number of rows: ";int nrow;
cin >> nrow;for(int i =0; i < nrow;++i){for(int j =0; j < nrow;++j){if(nrow - j > i +1)
cout <<".";else
cout <<"*";}
cout << endl;}return0;}
1.#include <iostream>int main(){ using namespace std; cout << "输入两个整数: "; int a,b; cin >> a; cin >> b; long sum = 0; for (int i = a; i <= b; ...