#include <iostream>
#include <cctype>
using namespace std; int main()
{
char in_put; do
{
cout << "Please enter the letters (enter @ exit):";
cin >> in_put; if (islower(in_put))
cout << "The uppercase of the letter " << in_put << " is " << char (toupper(in_put)) << ".\n";
else if (isupper(in_put))
cout << "The lowercase of the letter " << in_put << " is " << char (tolower(in_put)) << ".\n";
else if (in_put != '@')
cout << "Please enter the letters!\n";
} while (in_put != '@'); cout << "Exit!\n"; system("pause");
}

#include <iostream>
using namespace std;
const int MAX = ; int main()
{
double in_put[MAX];
double avg = ;
int sum; cout << "Please enter no more than " << MAX << " digits.\n";
for (int i = ; i < MAX; ++i)
{
cout << "The " << i + << "th digit is: ";
if (cin >> in_put[i])
avg += in_put[i];
else
{
cout << "Not digit! Exit!\n";
sum = i;
break;
}
} avg = avg / sum;
int num_a=, num_b=;
for (int i = ; i < sum; ++i)
{
if (in_put[i] > avg)
num_a += ;
else
num_b += ;
} cout << "The average of these numbers is: " << avg << ".\n"
<< "There are " << num_a << " numbers larger than the average value.\nAnd "
<< num_b << " numbers not larger than the average value.\n"; system("pause");
}

#include <iostream>
using namespace std;
int show(char); int show(char ch)
{
int flag = ;
cout << "A maple is a ";
switch(ch)
{
case 'c':
cout << "carnivore.\n";
break;
case 'p':
cout << "pianist.\n";
break;
case 't':
cout << "tree.\n";
break;
case 'g':
cout << "game.\n";
break;
default:
cout << "Please enter c,p,t,g :";
flag = ;
}
return flag;
} int main()
{
char ch;
int flag; cout << "Please enter one of the following choices:\n"
<< "c) carnivore\t" << "p) pianist\n"
<< "t) tree\t\t" << "g) game\n"; do
{
cin >> ch;
flag=show(ch);
} while (flag == ); system("pause");
}

#include <iostream>
using namespace std;
const int strsize = ;
const int MAX = ; struct bop
{
char fullname[strsize];
char title[strsize];
char bopname[strsize];
int preference;
}; int show(char ch, bop mmm[MAX])
{
int flag = ;
switch (ch)
{
case 'a':
for (int i = ; i < MAX; ++i)
{
cout << mmm[i].fullname<<endl;
}
break;
case 'b':
for (int i = ; i < MAX; ++i)
{
cout << mmm[i].title << endl;
}
break;
case 'c':
for (int i = ; i < MAX; ++i)
{
cout << mmm[i].bopname << endl;
}
break;
case 'd':
for (int i = ; i < MAX; ++i)
{
switch(mmm[i].preference)
{
case :cout << mmm[i].fullname << endl;
break;
case :cout << mmm[i].title << endl;
break;
case :cout << mmm[i].bopname << endl;
break;
}
}
break;
case 'q':
flag = ;
break;
default:
cout << "Please enter a,b,c,d,q!\n";
}
return flag;
} int main()
{
bop all_peo[MAX] =
{
{ "QQQ","NiCai","qqq", },
{ "WWW","BuCai","www", },
{ "EEE","CaiBuCai","eee", },
{ "RRR","JiuBuCai","rrr", },
{ "TTT","LaDao","ttt", }
}; char ch;
int flag; cout << "Benevolent Order of Programmers Report\n"
<< "a. display by name\t" << "b. display by title\n"
<< "c. display by bopname\t" << "d. display by preference\n"
<< "q. quit\n"; cout << "Enter your choice:";
cin >> ch; flag = show(ch, all_peo); while (flag == )
{
cout << "Next choice: ";
cin >> ch;
flag=show(ch, all_peo);
}
cout << "Bye!\n"; system("pause");
}

#include <iostream>
using namespace std;
const float Tax_1 = 0.1;
const float Tax_2 = 0.15;
const float Tax_3 = 0.2;
const int Tax_come1 = ;
const int Tax_come2 = ;
const int Tax_come3 = ; double Tax(double); int main()
{
double income; cout << "Please enter income(enter a negative or non-numeric exit): ";
while (cin >> income)
{
if (income < )
break;
double tax;
tax=Tax(income);
cout << "Income tax: " << tax << "\nNext enter: ";
}
cout << "Bye!\n"; system("pause");
} double Tax(double income)
{
double tax;
double num1 = income - Tax_come3;
double num2 = income - Tax_come2;
double num3 = income - Tax_come1;
if (num1 > )
tax =(Tax_come2 - Tax_come1)*Tax_1 + (Tax_come3 - Tax_come2)*Tax_2 + num1 * Tax_3;
else
{
if (num2 > )
tax =(Tax_come2 - Tax_come1)*Tax_1 + num2 *Tax_2;
else
{
if (num3 > )
tax = num3 * Tax_1;
else
tax = ;
}
} return tax;
}

#include <iostream>
#include <string>
using namespace std; struct potron
{
string name;
double money;
}; int main()
{
int num;
cout << "Please enter the number of donors: ";
cin >> num; potron *potrons = new potron[num];
for (int i = ; i < num; ++i)
{
cout << "Please enter the " << i + << "th donor name:";
cin.ignore();
getline(cin,potrons[i].name);
cout << "Please enter the number of " << i + << "th donor contributions:";
cin >> potrons[i].money;
} int flag1 = , flag2 = ;
cout << "Grand Potrons\n";
for (int i = ; i < num; ++i)
{
if (potrons[i].money > )
{
cout << potrons[i].name << " : " << potrons[i].money << endl;
flag1 = ;
}
}
if (flag1 == )
cout << "None!\n"; cout << "Potrons\n";
for (int i = ; i < num; ++i)
{
if (!(potrons[i].money > ))
{
cout << potrons[i].name << " : " << potrons[i].money << endl;
flag2 = ;
}
}
if (flag2 == )
cout << "None!\n"; system("pause");
}

#include <iostream>
#include <cctype>
using namespace std;
const int MAX = ; int main()
{
char words[MAX][];
char ch;
int num_y = , num_f = , num_o = ; cout << "Enter words (q to quit):\n";
for (int i = ; i < MAX; ++i)
{
cin >> words[i];
ch = words[i][];
if (ch == 'q')
break;
if (isalpha(ch))
{
switch (ch)
{
case 'a':;
case 'e':;
case 'i':;
case 'o':;
case 'u':
num_y += ;
break;
default:
num_f += ;
break;
}
}
else
num_o += ;
} cout << num_y << " beginning with vowels\n";
cout << num_f << " beginning with consonants\n";
cout << num_o << " others\n";
system("pause");
}

#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
const int SIZE = ; int main()
{
char filename[SIZE];
ifstream infile;
cout << "Enter name of data file: ";
cin.getline(filename, SIZE);
infile.open(filename);
if (!infile.is_open())
{
cout << "Could not open the file " << filename << endl;
cout << "Program terminating.\n";
exit(EXIT_FAILURE);
} int count=;
char ch; infile >> ch;
while (infile.good())
{
++count;
// ch= infile.get();//读取空白字符
infile >> ch;//不读取空白字符
} cout << "The number of characters in the file is: " << count << endl; system("pause");
}

#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
const int SIZE = ; struct potron
{
string name;
double money;
}; int main()
{
char filename[SIZE];
ifstream infile;
cout << "Enter name of data file: ";
cin.getline(filename, SIZE);
infile.open(filename);
if (!infile.is_open())
{
cout << "Could not open the file " << filename << endl;
cout << "Program terminating.\n";
exit(EXIT_FAILURE);
} int num;
infile >> num; potron *potrons = new potron[num];
for (int i = ; i < num; ++i)
{
infile.ignore();
getline(infile, potrons[i].name);
infile >> potrons[i].money;
} int flag1 = , flag2 = ;
cout << "Grand Potrons\n";
for (int i = ; i < num; ++i)
{
if (potrons[i].money > )
{
cout << potrons[i].name << " : " << potrons[i].money << endl;
flag1 = ;
}
}
if (flag1 == )
cout << "None!\n"; cout << "Potrons\n";
for (int i = ; i < num; ++i)
{
if (!(potrons[i].money > ))
{
cout << potrons[i].name << " : " << potrons[i].money << endl;
flag2 = ;
}
}
if (flag2 == )
cout << "None!\n"; system("pause");
}

最新文章

  1. psql-08表:触发器
  2. AES--高级数据加密标准
  3. C#根据网址生成静态页面
  4. 使用fiddler查看https请求
  5. JavaScript - 事件流
  6. fragment的生命周期及其各个周期方法的作用
  7. NODE学习:利用nodeJS去抓网页的信息
  8. 使用msgfmt编译多语言文件
  9. strus2与spring3 mvc的差别
  10. 一步步优化JVM二:JVM部署模型和JVM Runtime
  11. IntelliJ IDEA 2017.1.4 x64配置说明
  12. Android Ndef Message解析
  13. hdu 1588 求f(b) +f(k+b) +f(2k+b) +f((n-1)k +b) 之和 (矩阵快速幂)
  14. .NET MVC-去掉验证
  15. sublime text 给选中项插入编号
  16. AES加密时抛出java.security.InvalidKeyException: Illegal key size or default parametersIllegal key size or default parameters
  17. 第三篇:关于TIME_WAIT状态
  18. POJ3690 Constellations
  19. flink写入mysql的两种方式
  20. linux安装x264 ffmpeg

热门文章

  1. (转)使用XCode6打开项目以后再用XCode5出现的问题fatal error: malformed or corrupted AST file: &#39;Unable to load module
  2. phper
  3. vmware tool安装
  4. c语言的字符串拷贝函数的精简
  5. 【Redis学习之九】Redis集群:Twemproxy和HA
  6. python的subprocess的简单使用和注意事项
  7. jquery-easyui combobox combogrid 级联不可编辑实例
  8. 保护Hadoop集群三大方法
  9. TED #10# A rite of passage for late life
  10. 02: SocketServer服务