#include//#include #include #include typedef struct { std ::string manufacturer; int p_year;} Car;typedef Car * CarPtr;/*----------------------- exercise 1 -----------------------------*///int main(void)//{// using namespace std;// // int head;// int tail;// int sum = 0;//// cout << "Please enter two interger:";// cin >> head;// cin >> tail;// // for (int i = head; i < tail + 1; i++){// sum += i; // }// // cout << "sum = " << sum << endl; //}/*----------------------- exercise 2 -----------------------------*///int main(void)//{// using namespace std;//// const int ArSize = 101;// array factorials;// factorials[0] = factorials[1] = 1;//// 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;//}///*----------------------- exercise 3 -----------------------------*///int main(void)//{// using namespace std;//// cout << "Enter 0 to quit!" << endl;// cout << "Please enter the numbers : ";//// int num;// int sum = 0;//// cin >> num;// while (0 != num){// sum += num;// cout << "Sum = " << sum << endl;// cout << "Please enter the numbers : ";// cin >> num;// }// return 0;//}/*----------------------- exercise 4 -----------------------------*///int main(void)//{// using namespace std;//// const double ori_deposit_daphne = 100;// const double ori_deposit_cleo = 100;// double cur_deposit_daphne = ori_deposit_daphne;// double cur_deposit_cleo = ori_deposit_cleo;// double interest_daphne = 0;// double interest_cleo = 0;// int year = 0;//// do{// interest_daphne = ori_deposit_daphne * 0.1;// interest_cleo = cur_deposit_cleo * 0.05;// cur_deposit_daphne += interest_daphne;// cur_deposit_cleo += interest_cleo;// year++;// }while (cur_deposit_cleo <= cur_deposit_daphne);//// cout << year << " Years later Cleo's income surpass Daphne's income" << endl;// cout << "Deposit of Daphne is " << cur_deposit_daphne << endl;// cout << "Deposit of Cleo is " << cur_deposit_cleo << endl;// return 0;//}/*----------------------- exercise 5 -----------------------------*///int main(void)//{// using namespace std;//// const string mounth[12] = {"January", "February", "March", "April", "May", "June",// "July", "August", "September", "October", "November", "December"};// int sales[12];// int TotalSales = 0;//// for (int i = 0; i < 12; i++){// cout << mounth[i] << "'s sales is : ";// cin >> sales[i];// TotalSales += sales[i];// }// // cout << "Total sales are : " << TotalSales << endl;// return 0;//}/*----------------------- exercise 7 -----------------------------*///int main(void)//{// using namespace std;//// cout << "How many cars do you wish to catalog ? ";//// int c_cars;// // cin >> c_cars;// cin.get();// CarPtr car = new Car [c_cars];//// int num = 1;// while (c_cars > 0){// cout << "\"Car #" << num << '\"' << endl;// cout << "Please enter the make: ";// getline(cin, car[num-1].manufacturer);// cout << "Please enter the year made :";// cin >> car[num-1].p_year;// cin.get();// num++;// c_cars--;// }//// cout << car[0].manufacturer << car[0].p_year << endl; // cout << car[1].manufacturer << car[1].p_year << endl; // delete [] car;// // return 0;//}/*----------------------- exercise 8 -----------------------------*///int main(void)//{// using namespace std;//// char word[20];// int c_word = 0;//// cout << "Enter words(to stop,type the word done):" << endl;//// while ((cin >> word) && strcmp(word, "done")){// c_word++;// }// // cout << "You entered a total of " << c_word << " words" << endl;// return 0;//}/*----------------------- exercise 9 -----------------------------*///int main(void)//{// using namespace std;//// string word;// int c_word = 0;//// cout << "Enter words(to stop,type the word done):" << endl;//// while ((cin >> word) && (word != "done")){// c_word++;// }//// cout << "You entered a total of " << c_word << " words" << endl;// return 0;//}/*----------------------- exercise 10 -----------------------------*///int main(void)//{// using namespace std;//// int c_row;// int cur_row;//// cout << "Enter number of rows: ";// cin >> c_row;//// for (cur_row = 1; cur_row <= c_row; cur_row++){// for (int i = 0; i < c_row - cur_row; i++){// cout << '.';// }//// for (int i= 0; i < cur_row; i++){// cout << '*';// }//// cout << endl;// }//// return 0;//}
水平有限,若有错误之处还请指教,谢谢!