# c++primer plus 第六章习题

#include<iostream>
#include<stdlib.h>
//第六章习题
using namespace std;
int main()
{
char ch;
cin.get(ch);
while (ch != '@')
{
if (isalpha(ch))
{
if (islower(ch))
cout << char(ch - 32);
else if (isupper(ch))
cout << char(ch + 32);

}
else if(!(isdight(ch)))
cout << ch;
cin.get(ch);
}
system("pause");
return 0;
}

#include<iostream>
#include<stdlib.h>
//第六章习题
using namespace std;
int main()
{
double donation[10];
double average=0,sum=0;
int i=0,num=0;
while (i<10&&cin>>donation[i])
{
sum += donation[i];
i++;
}
average = sum / i;
cout << "平均值：" <<average << endl;
for (int j = 0; j < i; j++)
{
if (donation[j]>average)
{
num++;
}
}
cout << "超过平均值的数字个数：" << num << endl;
system("pause");
return 0;
}

#include<iostream>
#include<stdlib.h>
//第六章习题
using namespace std;
int main()
{
char choice;

while (cin>>choice&&choice!= 'c' && choice != 'p' && choice != 't' && choice != 'g')
{
cout << "Please enter c p t g :";
}
switch (choice)
{
case 'c': cout << "I love you!\n"; break;
case 'p':cout << "I hate you!\n"; break;
case't':cout << "I miss you!\n"; break;
case'g':cout << "oh my gald!\n"; break;
}
system("pause");
return 0;
}
{
cout << "Please enter c p t g :\n"
"c) carnivore          p) pianist\n"
"t) tree               g) game\n";
}

#include<iostream>
#include<stdlib.h>
//第六章习题
using namespace std;
int main()
{
char choice;
cin >> choice;
while (choice != 'q')
{
switch (choice)
{
case 'a': cout << "I love you!\n"; break;
case 'b':cout << "I hate you!\n"; break;
case'c':cout << "I miss you!\n"; break;
case'd':cout << "oh my gald!\n"; break;
}
cin >> choice;
}

system("pause");
return 0;
}
{
cout << "Please enter a b c d q :\n"
"a) carnivore          b) pianist\n"
"c) tree               c) game\n"
"q) quit\n"
}

#include<iostream>
#include<stdlib.h>
//第六章习题
using namespace std;
int main()
{
int choice;
double tax;
while (cin >> choice)
{
if (choice < 0)
break;
else if (choice <= 5000)
{
tax = 0;
cout << "Tax:" << tax << endl;
}
else if (choice>5000&&choice<=15000)
{
tax = (choice-5000)*0.1;
cout << "Tax:" << tax << endl;
}
else if (choice>15000 && choice <= 35000)
{
tax = (choice-15000)*0.15 + 10000 * 0.1;
cout << "Tax:" << tax << endl;
}
else
{
tax = (choice-35000)*0.2 + 20000 * 0.15 + 10000 * 0.1;
cout << "Tax:" << tax << endl;
}
}

system("pause");
return 0;
}

#include<iostream>
#include<stdlib.h>
#include<string>
#include<cstring>
//第六章习题
using namespace std;
struct donate
{
string  name;
double  money;
};
int main()
{

int num;
cout << "Please enter donate numbers:";
cin >> num;
cin.get();
donate *d1 = new donate[num];
for (int i = 0; i < num; i++)
{
getline(cin,d1[i].name);
cin >> d1[i].money;
cin.get();
}
cout << "Grand Patrons:";
int counter=0;
for (int i = 0; i < num; i++)
{
if (d1[i].money>10000)
{
cout << d1[i].name << '\t'; counter++;
}

}
if (counter == 0)
{
cout << "None !" << endl;
}
cout << '\n';
counter = 0;
cout << "Patrons:";
for (int i = 0; i < num; i++)
{
if (d1[i].money < 10000)
{
cout << d1[i].name << '\t'; counter++;
}
}
cout << "\n";
if (counter == 0)
{
cout << "None !" << endl;
}
delete[]d1;
system("pause");
return 0;
}

#include<iostream>
#include<stdlib.h>
#include<string>
#include<cstring>
//第六章习题
using namespace std;

int main()
{
cout << "Enter words(q to quit):";
string s;
int counter=0,i=0,j=0;
while (cin >> s)
{
if (s[0] == 'q' || s[0] == 'Q')
break;
else if (s[0] == 'a' || s[0] == 'A' || s[0] == 'e' || s[0] == 'E' ||
s[0] == 'i' || s[0] == 'I')
counter++;
else if (s[0] == 'b' || s[0] == 'c')
i++;
else
j++;
}
cout << counter << "words begin with vowels" << endl;
cout << i << "words begin with constants" << endl;
cout << j << "words begin with others" << endl;
system("pause");
return 0;
}

#include<iostream>
#include<stdlib.h>
#include<fstream>
//第六章习题
using namespace std;

int main()
{
ifstream infile;
int count=0;
infile.open("1.txt");
char s;
infile >> s;
while (infile.good())
{
++count;
infile >> s;
}
cout << count << " Items!\n";
infile.close();
system("pause");
return 0;
}

#include<iostream>
#include<stdlib.h>
#include<string>
#include<cstring>
//第六章习题
using namespace std;
struct donate
{
string  name;
double  money;
};
int main()
{

int num;
cout << "Please enter donate numbers:";
cin >> num;
cin.get();
donate *d1 = new donate[num];
for (int i = 0; i < num; i++)
{
getline(cin,d1[i].name);
cin >> d1[i].money;
cin.get();
}
for (int i = 0; i < num; i++)
{
cout <<"Name:"<< d1[i].name <<endl;
cout <<"Money:"<< d1[i].money << endl;
}
delete[]d1;
system("pause");
return 0;
}


#### C++ Primer Plus 第六版 所有章节课后编程练习答案

2017-11-01 20:32:16

#### c++primer第五版课后练习答案（第六章）

2014-12-18 20:09:53

#### C++ Primer Plus（第六版）第六章复习题答案

2018-05-10 16:01:27

#### 《C++ Primer Plus（第6版）中文版》编程练习答案第6-10章

2014年07月18日 321KB 下载

#### c++ primer plus(第6版)中文版 第六章编程练习答案

2014-05-05 13:11:21

#### c++_primer_plus(第六版)第二至第六章课后编程练习全部答案

2014年06月13日 111KB 下载

#### c++ primer plus第十一章习题答案

2014-12-30 11:39:51

#### 《C++ Primer Plus（第六版）》（47）（总结）

2017-01-06 11:25:22

#### C++ Primer Plus第五版 第六章 编程练习答案

2017-10-20 21:52:23

#### C++PrimerPlus 课后编程练习答案

2016年08月31日 106KB 下载