欢迎来到天天文库
浏览记录
ID:23285518
大小:337.50 KB
页数:16页
时间:2018-11-06
《西安交大c++随堂练习》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、西安交通大学实验报告一.实验目的(1)标准库、流概述(2)输入输出流的使用。(3)格式化I/O、文件处理二.实验内容1.按下面格式输出圆周率的值。33.13.143.1413.14153.141593.1415923.14159261.程序源代码#include#include#includeusingnamespacestd;intmain(){doublea=3.1415926;intplaces;for(places=1;places<=8;places++){doubleb=4.5/pow(10.
2、0,places);cout.precision(places);cout<#include#includeusingnamespacestd;intmain(){charch;intline=1;ifstreamin("01.cpp");if(!in){cout<<"不能读入文件";return1;}cout<3、w(4)<#include#include#includeusingnamespacestd;intmain(){charch;4、intn=1;ifstreamfin("11.txt");if(!fin){cout<<"打开失败"<5、的个数:"<#include#include#includeusingnamespacestd;6、classemployee{public:charnum[20];charname[10];charplace[10];intage;employee(){}employee(char*num,char*name,char*place,intAge){strcpy(this->name,name);strcpy(this->num,num);strcpy(this->place,place);age=Age;}voidshowme(){cout<7、ployeeemp[6]={employee("001011","张三","北京",20),employee("001012","李四","上海",23),employee("001013","王丽","广州",21),employee("001014","王刚","陕西",18),employee("001015","Kimi","台湾",25),employee("001016","Cindy","陕西",20)};ofstreamfile1("file.dat");if(!file1){cout<<"打开失败"<8、inti=0;i<6;i++)file1.write((char*
3、w(4)<#include#include#includeusingnamespacestd;intmain(){charch;
4、intn=1;ifstreamfin("11.txt");if(!fin){cout<<"打开失败"<5、的个数:"<#include#include#includeusingnamespacestd;6、classemployee{public:charnum[20];charname[10];charplace[10];intage;employee(){}employee(char*num,char*name,char*place,intAge){strcpy(this->name,name);strcpy(this->num,num);strcpy(this->place,place);age=Age;}voidshowme(){cout<7、ployeeemp[6]={employee("001011","张三","北京",20),employee("001012","李四","上海",23),employee("001013","王丽","广州",21),employee("001014","王刚","陕西",18),employee("001015","Kimi","台湾",25),employee("001016","Cindy","陕西",20)};ofstreamfile1("file.dat");if(!file1){cout<<"打开失败"<8、inti=0;i<6;i++)file1.write((char*
5、的个数:"<#include#include#includeusingnamespacestd;
6、classemployee{public:charnum[20];charname[10];charplace[10];intage;employee(){}employee(char*num,char*name,char*place,intAge){strcpy(this->name,name);strcpy(this->num,num);strcpy(this->place,place);age=Age;}voidshowme(){cout<7、ployeeemp[6]={employee("001011","张三","北京",20),employee("001012","李四","上海",23),employee("001013","王丽","广州",21),employee("001014","王刚","陕西",18),employee("001015","Kimi","台湾",25),employee("001016","Cindy","陕西",20)};ofstreamfile1("file.dat");if(!file1){cout<<"打开失败"<8、inti=0;i<6;i++)file1.write((char*
7、ployeeemp[6]={employee("001011","张三","北京",20),employee("001012","李四","上海",23),employee("001013","王丽","广州",21),employee("001014","王刚","陕西",18),employee("001015","Kimi","台湾",25),employee("001016","Cindy","陕西",20)};ofstreamfile1("file.dat");if(!file1){cout<<"打开失败"<8、inti=0;i<6;i++)file1.write((char*
8、inti=0;i<6;i++)file1.write((char*
此文档下载收益归作者所有