已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1 注释 这些程序是唐刀在学习的时候编写的 其中可能存在错误和不足 大家注释 这些程序是唐刀在学习的时候编写的 其中可能存在错误和不足 大家 做个参考就好 做个参考就好 1 include include int main using namespace std cout 请输入字符 符号结束 endl char ch while cin get ch else 如果 ch 是小写字母 cout char toupper ch 转换为大写字母然后输出 else if isdigit ch 非数字非字母则原样输出 cout ch else continue return 0 2 include using namespace std int main double arr 10 0 0 0 0 0 0 0 0 0 0 cout 输入 10 个值 当输入为非数字时结束 endl int count 0 2 while count arr count count double sum 0 double aver 0 for int i 0 i count i sum arr i aver sum count int n 0 for int j 0 javer n cout 输入 count 个数据 数据的平均值为 aver 共有 n 个数据大于平均值 endl getchar getchar getchar return 0 3 include using namespace std int main cout Please enter one of following choices endl cout c carnivore endl cout p pianist endl cout t tree endl cout g game temp while temp c 3 switch temp case c cout A maple is a carnivore endl break case p cout A maple is a pianist endl break case t cout A maple is a tree endl break case g cout A maple is a game endl break return 0 4 include using namespace std struct bop char fullname 20 char title 20 char bopname 20 int preference int main bop member 5 Wimp Macho leader wm 1 Raki Rhodes member1 rr 2 Celia Laiter member2 cl 3 Hoppy Hipman member3 hh 4 Pad Hand member4 ph 5 cout benevolent order of programmers report endl cout a display by name endl cout b display by title endl cout c display by bopname endl cout d display by preference endl cout q quit tempi 5 i cout member i fullname endl break case b for int i 0 i 5 i cout member i title endl break case c for int i 0 i 5 i cout member i bopname endl break case d for int i 0 i 5 i cout member i preference endl break default break cout Bye endl return 0 5 include using namespace std int main int money 存储用户输入 double tax 存储需要缴纳的税金 int temp 根据用户输入得出的用户需要缴税的等级 while cin money else if money 5001 temp 1 else if money 15001 temp 2 else temp 3 switch temp 根据上面规定的等级 计算税金 case 0 tax 0 break case 1 tax money 5000 0 1 break case 2 tax money 15000 0 15 10000 0 1 break case 3 tax money 35000 0 2 20000 0 15 10000 0 1 break cout You should pay tax tvarps endl getchar 程序运行时方便阅读 getchar getchar return 0 6 include include include using namespace std struct donation 结构体 存储捐款者信息 string name double money int main int n of donation 0 6 cout 请输入捐款者数目 n of donation donation list new donation n of donation 创建动态分配的结构数组 for int i 0 i n of donation i 输入捐款者的信息 cout 输入第 i 1 位捐款者的信息 endl cout 名字 cin sync getline cin list i name cout list i money int temp 0 记录有没有人的捐款大于一万元 cout 重要捐款人 endl for int i 0 i10000 cout list i name list i money endl temp if temp 0 cout 此项目没有人 endl temp 0 cout 捐款人 endl for int i 0 i n of donation i if list i money 10000 cout list i name list i money endl temp if temp 0 cout 此项目没有人 endl delete list 释放内存 getchar 程序运行时方便阅读 getchar return 0 7 7 include include include include using namespace std int main int yuanyin 0 int fuyin 0 int qita 0 string word char temp cout Enter words q to quit word while word q switch temp 计算 case a yuanyin break case e yuanyin break case i yuanyin break case o yuanyin break case u yuanyin break default fuyin else 其他 qita cin word cout yuanyin words beginning with vowels endl 输出 cout fuyin words beginning with consonants endl cout qita others endl getchar 程序运行时方便阅读 getchar 8 return 0 8 include include include include using namespace std int main char filename 20 ifstream inFile cout Enter name of file endl cin getline filename 20 inFile open filename if inFile is open cout could not open the file n cout value while inFile good count inFile value if inFile eof cout End of file reached n else if inFile fail cout Input terminated by data mismatch n else cout Input terminated for unknown reason n if count 0 cout None of letter else cout Number of letters count endl inFile close 9 getchar 程序运行时方便阅读 getchar return 0 9 include include include include const int MAX 60 struct Patrons std string name double money int main using namespace std int n int sign 0 看看是否须要输出 none char filename MAX ifstream inFile cout 请输入文件名 cin getline filename MAX inFile open filename if inFile is open cout 无法打开文件 filename endl cout Program terminating n 开始从文件读入 Patrons n Patrons new Patrons n for int i 0 i n Patrons i money inFile close 关闭文件 10 cout endl endl Grand Patrons endl endl for i 0 i10000 cout n Patrons i n
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026汕头市教师招聘面试题及答案
- 2026年山东省春季高考数学《三角函数与解三角形》专项训练(含逐题解析)
- 2026年江西南昌市高三二模高考英语试卷试题(含答案详解)
- 项目协作平台权限设置
- 2026年幼儿园简介介绍
- 2026年幼儿园家儿歌
- 2026年幼儿园桃花
- 2026年安全 幼儿园
- 深度解析(2026)《GBT 22301-2021干迷迭香》宣贯培训
- 深度解析(2026)《GBT 21547.2-2008 VME总线对仪器的扩展 第2部分:TCPIP-VXI总线接口规范》
- 高中英语2024届高考应用文常见亮眼句型(共十八类)
- ISO 15609-1 2019 金属材料焊接工艺规程和评定-焊接工艺规程-电弧焊(中文版)
- (正式版)JBT 10437-2024 电线电缆用可交联聚乙烯绝缘料
- 小学语文心理健康教育案例分析
- 文旅融合和文化旅游
- 智慧停车场经济效益分析
- 惠州市龙门县事业单位真题2023
- 电动吸引器简要操作流程图
- 2022-2023学年河北省廊坊三河市数学六年级第二学期期末质量跟踪监视试题含解析
- 云南省农村留守儿童现状调研报告
- YY/T 1841-2022心脏电生理标测系统
评论
0/150
提交评论