编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
struct patron
{
double mon;
string name;
};
int main()
{
int num,count1=0,count2=0;
ifstream fin;
char filename[20];
cout<<"Enter name of data file: ";
cin.get(filename,20);
fin.open(filename);
if(!fin.is_open())
{
cout<<"Could not to open the file "<<filename<<endl;
cout<<"Program termination.\n";
exit(EXIT_FAILURE);
}
fin>>num;
fin.get();
patron *newp=new patron[num];
for(int i=0;i<num;i++)
{
getline(fin,newp[i].name);
fin>>newp[i].mon;
fin.get();
}
cout<<"Grand Patrons:\n";
for(int j=0;j<num;j++)
{
if(newp[j].mon>10000)
{
cout<<newp[j].name<<":"<<newp[j].mon<<endl;
count1++;
}
if(count1==0)
cout<<"none\n";
cout<<"Patrons:\n";
for(int k=0;k<num;k++)
{
if(newp[k].mon<=10000)
{
cout<<newp[k].name<<":"<<newp[k].mon<<endl;
count2++;
}
}
if(count2==0)
cout<<"none\n";
}
delete [] newp;
system("pause");
return 0;
}
编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9的更多相关文章
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习8
#include <iostream> #include <fstream> #include <cstdlib> const int SIZE=20; using ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习7
#include <iostream> #include <string> #include <cctype> using namespace std; int m ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习6
#include <iostream> #include <string> using namespace std; const int MSIZE=100; struct j ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习5
#include <iostream> using namespace std; const double N1=35000; const int N2=15000; const int ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习4
#include <iostream> using namespace std; const int strsize=30; const int BOPSIZE=5; void showm ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习3
#include <iostream> using namespace std; void showmenu(void) { cout<<"Please enter ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习2
#include <iostream> #include <cctype> using namespace std; const int MAXSIZE=10; int mai ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习1
#include <iostream>#include <cctype>using namespace std;int main(){ char ch; while((ch=c ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第5章编程练习9
#include <iostream>using namespace std;int main(){ int num; cout<<"Enter number of ...
随机推荐
- L1-Day9
1.学习让我感觉很棒.(什么关系?动作 or 描述?主语部分是?) [我的翻译]Learning makes me that feel good. [标准答案]Lear ...
- kali下的webshell工具-Weevely
Weevely ------------------------------------------------ 主要特点: · 隐蔽的类终端的PHP webshell · ...
- python matplotlib 简单生成图
import numpy as np import pandas as pd from matplotlib import pyplot as plt data = pd.DataFrame([[1, ...
- spring boot 框架设计步骤
spring boot 框架设计步骤: 1.poem.xml配置 2.application.yml配置 3.entiry实体 4.realm.Myrealm extends AuthorizingR ...
- 「luogu2569」[ZJOI2006] 书架
「luogu2569」[ZJOI2006]书架 题目大意 给定一个长度为 \(n\) 序列,序列中第 \(i\) 个元素有编号 \(a_i(a_i \in \Z \cap [1,n])\),需要支持五 ...
- Go语言--数组、切片、
3.1 数组--固定大小的连续空间 3.1.1 声明数组 写法 var 数组变量名 [元素数量]T 说明: 变量名就是使用时的变量 元素的数量可以是表达式,最后必须为整型数值 T 可是是任意基本类型, ...
- django ajax 及批量插入数据 分页器
``` Ajax 前端朝后端发送请求都有哪些方式 a标签href GET请求 浏览器输入url GET请求 form表单 GET/POST请求 Ajax GET/POST请求 前端朝后端发送数据的编码 ...
- 2018年最新JAVA面试题总结之框架(4)
转自于:https://zhuanlan.zhihu.com/p/40098726 1.谈谈对spring框架的了解 ,spring有什么作用(IOC,AOP),spring的核心是什么?回答:Spr ...
- 分享:使用 TypeScript 编写的游戏代码
<上篇博客>我写出了我一直期望的 JavaScript 大型程序的开发模式,以及 TS(TypeScript) 的一些优势.博客完成之后,我又花了一天时间试用 TS,用它来重构之前编写的一 ...
- numpy的数组常用运算练习
import numpy as np # 一维数组 print('==========# 一维数组===========') A = np.array([1, 2, 3, 4]) print(A) # ...