编程菜鸟的日记-初学尝试编程-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 ...
随机推荐
- MySQL命令行查询乱码解决方法
转自Agoly的博客,原文链接https://www.cnblogs.com/qmfsun/p/4846467.html 感谢博主Agoly这篇文章说的很详细很透彻. MySQL会出现中文乱码的原因不 ...
- Grunt 一个专为JavaScript提供的构建工具
新手最好找个视频来看看, Grunt的配置及使用(压缩合并js/css) - 每天都记录一点点! - CSDN博客https://blog.csdn.net/playboyanta123/articl ...
- javascript闭包学习
(function(){})()===>>>>函数会被立即执行function(){}是一个函数用括号包起来表示是函数表达式再加()表示函数自执行 如何理解闭包?1.定义和用 ...
- springboot接口访问权限AOP实现
场景 现在有个系统,很多接口只需要登录就可以访问,但是有些接口需要授予并验证权限.如果用注解controller的方式控制接口的权限呢? 1.注解声明代码 这个注解是要装饰在controller接口上 ...
- html注意事项
行级元素只能嵌套行级元素 块级元素可以嵌套任何元素 格力 p标签不能嵌套div a标签不能嵌套a标签
- 高可用Redis(三):Hash类型
1.哈希类型键值结构 哈希类型也是key-value结构,key是字符串类型,其value分为两个部分:field和value 其中field部分代表属性,value代表属性对应的值 上面的图里,us ...
- 协议形式化分析Scyther 资料整理
1.性能分析 目前来说形式化的分析已经成为安全协议的一种很流行的方法,但是每种工具都用其不同适合的协议,Scyther软件是一种形式化分析工具,极大的促进了协议的分析和设计,scyther工具在运行界 ...
- 使用Django的时候,页面请求正常,也没有报任何错误,甚至连警告都没有的情况下,页面却还是原地不动或者闪一下或者无限显示加载动画的情况下的解决办法
这个问题描述比较笼统,但根据我目前遇到过两种情况来看,似乎都比较重要而且实用,所以打算分别讲述一下. 说明:Django的版本是Django2.0 第一种:URL配置错误 页面闪一下,却原地不动,可能 ...
- python的学习之路(二)
1.字符串内置功能练习#!/usr/bin/env python# *_*coding:utf-8 *_*# Author: harsonname = 'harson'name =str('harso ...
- MyBatis insert/delete/update 的返回值
insert,返回值是:新插入行的主键(primary key):需要包含<selectKey>语句,才会返回主键,否则返回值为null. <insert id="inse ...