编程菜鸟的日记-初学尝试编程-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 ...
随机推荐
- 线程——自定义多线程task
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 移动文件(git mv)
使用git mv命令将mian.c移动为main2.c $ git mv main.c main2.c D:\Git\test (master -> origin) $ git status O ...
- 中国 A 股纳入 MSCI
1 .什么是 MSCI MSCI 是美国指数编制公司 --- 美国明晟公司的简称. 是一家股权,固定资产,对冲基金,股票市场指数的供应商. MSCI 旗下编制了多种指数,他们把全球股票市场分成发达国家 ...
- 20175306 MyCP博客总结
课后必做题:MyCP总结 cp命令了解: · 作用:cp指令用于复制文件或目录,如同时指定两个以上的文件或目录,且最后的目的地是一个已经存在的目录,则它会把前面指定的所有文件或目录复制到此目录中.若同 ...
- EOCS跨链核心技术内幕
EOCS跨链技术的核心就是ICP模块,ICP即Inter Chain Protocol(跨链交互协议),下面着重介绍ICP工作原理和实现细节. Inter Chain Protocol(ICP) IC ...
- Node Graph ......
以前写过好多次,但是都没写完....主要是节点树的执行过程.这次打算好好写完. 这次目的是写一个 类似houdini sop下的 管理过程 目的是把大量流程中的杂乱比如后台处理,Arnold-> ...
- osg做的路面项目
- LightOJ 1372 (枚举 + 树状数组)
题目 Link 输出序列中有多少个组合 {a1,a2,a3,a4,a5,a6}可以构成一个六边形. 分析 序列每个数都不相等. 所以可以设 a1<a2<a3<a4<a5< ...
- Python 正则表达式 flags 参数
flags参数 re.I IGNORECASE 忽略字母大小写 re.L LOCALE 影响 “w, “W, “b, 和 “B,这取决于当前的本地化设置. re.M MULTILINE 使用本标志后, ...
- Python IDLE配置清屏快捷键(Ctrl+L)
1.在Python\Lib\idlelib下,新建一个ClearWindow.py文件(没有时就新建),内容如下: """ Clear Window Extension ...