/*
//5.9.1
#include<iostream>
using namespace std;
int Sum(int m, int n) {
int sum = 0;
for (int i = m;i <= n;i++) {
sum += i;
}
return sum;
};
int main() {
int m, n;
cout << "Enter two number m,n :";
cin >> m;
cin >> n;
cout << "The sum is : " << Sum(m, n) << endl;
return 0;
}
*/
/*
//5.9.2
#include<iostream>
#include<array>
using namespace std;
int main() {
const int ArSize = 101;
array<long double, ArSize>factorials;
factorials[0] = factorials[1] = 1L;
for (int i = 2;i < ArSize;i++) {
factorials[i] = i * factorials[i - 1];
}
for (int i = 0;i < ArSize;i++) {
cout << i << " != " << factorials[i] << endl;
}
return 0;
}
*/
/*
//5.9.3
#include<iostream>
using namespace std;
int main() {
float a=1;
float b = 0;
while (a!=0) {
cout << "Enter a number: ";
cin >> a;
b = b + a;
cout << "Now the sum numbers is " << b << endl;
}
return 0;
}
*/
/*
//5.9.4
#include<iostream>
using namespace std;
int main() {
int n=1;
float Daphne = 110;
float Cleo = 105;
while (Cleo < Daphne) {
Daphne = Daphne + 10;
Cleo = Cleo * (1.05);
n += 1;
}
cout << n << endl;
cout << Daphne << endl;
cout << Cleo << endl;
return 0;
}
*/
/*
//5.9.5
#include<iostream>
using namespace std;
int main() {
string sale[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
int Sale[12];
int sum=0;
for (int i = 0;i < 12;i++) {
cout << "Please input the " << sale[i] << "'s sale: ";
cin >> Sale[i];
sum=sum+Sale[i];
}
cout << "This year's sale is: " << sum << endl;
return 0;
}
*/
/*
//5.9.6
#include<iostream>
using namespace std;
int main() {
string sale[]= {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };
int Sale[3][12];
int sum = 0;
for (int j = 0;j < 3;j++) {
for (int i = 0;i < 12;i++) {
cout << "Please input the " << sale[i] << "'s sale of the " << j+1 << " year: ";
cin >> Sale[j][i];
sum = sum + Sale[j][i];
}
}
cout << "This year's sale is: " << sum << endl;
return 0;
}
*/
/*
//5.9.7
#include <iostream>
#include<string>
using namespace std;
struct car {
string manufacturer;
int year;
};
int main() {
int car_num;
car* cars;
cout << "How many cars do you wish to catalog?";
cin >> car_num;
cin.get();//读取字符
cars = new car[car_num];
for (int i = 0; i < car_num; i++) {
cout << "Car #" << (i + 1) << endl;
cout << "Please enter the make:";
getline(cin, cars[i].manufacturer);
cout << "Please enter the year made:";
cin >> cars[i].year;
cin.get();
}
cout << "Here is your collection:" << endl;
for (int i = 0; i < car_num; i++) {
cout << cars[i].year << " " << cars[i].manufacturer << endl;
}
delete[] cars;
return 0;
}
*/
/*
//5.9.8
#include<iostream>
#include<string>
using namespace std;
int main() {
int sum = 0;
char words[256];
cout << "Enter words (to stop, type the word done):" << endl;
while (strcmp("done", words) != 0) {
sum += 1;
cin >> words;
}
cout << "You entered a total of " << sum-1 << " words." << endl;
return 0;
}
*/
/*
//5.9.9
#include<iostream>
#include<string>
using namespace std;
int main() {
int sum = 0;
string words;
cout << "Enter words (to stop, type the word done):" << endl;
while (words != "done") {
sum += 1;
cin >> words;
}
cout << "You entered a total of " << sum - 1 << " words." << endl;
return 0;
}
*/
/*
//5.9.10
#include<iostream>
using namespace std;
int main() {
int m;
cout << "Please input a number: ";
cin >> m;
for(int i=0;i<m;i++){
int n = 0;
for (int j = 0;j < m - i-1;j++) {
cout << " . ";
n += 1;
}
for (int j = 0;j < m - n;j++) {
cout << " * ";
}
cout << endl;
}
return 0;
}
*/