编程菜鸟的日记-初学尝试编程-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 ...
随机推荐
- python-类内置属性和内置方法
class A(): ''' 这是一个类 ''' banji=1 def __init__(self,name,age): self.name=name self.age=age def AA(sel ...
- Arduino语法-变量和常量
变量的声明: int led=11 一般变量的声明方法为类型名+变量名+变量初始化值.变量名的写法约定为首字母小写 变量的作用范围又称为作用域,变量的作用范围与该变量在哪儿声明有关,大致分为如下两种: ...
- 认识Modbus协议
1.什么是Modbus? Modbus协议是应用于电子控制器上的一种通用语言.通过此协议,控制器相互之间,控制器经由网络(例如以太网)和其它设备之间可以通信.Modbus协议定义了一个控制器能认识使用 ...
- 通过FileReader和FileWriter实现复制文件的方法。
public class CopyDemo { public static void main(String []args) { copyd(); } public static void copy ...
- L1-Day13
1.Being late is an unforgivable sin here.[我的翻译]在北京,迟到是不可饶恕的罪名.[标准答案]在这里迟到是不可原谅的.[对比分析]对自己的也是醉醉的了,Bei ...
- Balanced Number HDU - 3709
题目大意:若一个数以某个位置为支点,支点左右的加权和相同,这样的数被称为平衡数,求区间内平衡数的个数 思路:枚举支点位置,针对每个支点进行数位DP,但是0比较特殊,假设该数的长度为len,枚举len次 ...
- expect 批量自动部署ssh 免密登陆 之 三
#!/bin/expect -- ########################################## zhichao.hu #Push the id.pas.pub public k ...
- c编译步骤
这几天查编译问题时,在头文件中加入某些错误信息,却发现没有编译报错.想了一下可能是,还未进行到语法分析阶段. 这里再了解一下编译过程. 一般而言代码编译包含了四个阶段的处理,即预处理(也称预编译,Pr ...
- 运行maven命令的时候出现jre不正确
出错详情: Unable to locate the Javac Compiler in: C:\Program Files\Java\jre1.6.0_07\..\lib\tools.jar Ple ...
- JS中函数常见的表现形式以及立即执行函数
函数常见的几种表现形式: 1.一般形式(函数声明): 会进行函数的预解释,函数会进行声明和定义,在函数体前面或则后面都可以进行调用. 2.函数表达式(匿名函数): 会进行函数的预解析,函数会进行声明但 ...