五大排序法概要.doc

五大排序法概要

写入文本文件 #includeiostream #includefstream//关于文件操作的头文件 using namespace std; void main() { //将内存中的数据写入TXT文件 int Array[10]={1,2,3,4,5,6,7,8,9,10}; ofstream fp;//写文件对象 fp.open(data.txt,ios::out);//在磁盘上建文本文件data.txt //将内存中的数据写入该文件 if(!fp) { cout文件data.txt打开失败!endl; return; } for(int i=0;i9;i++) fpArray[i] ; fpArray[9]; fp.close();//关闭文件 //将磁盘上的TXT文件内容读入内存 ifstream fq;//定义一个读文件对象 int BufferArray[50];//定义一个缓冲区数组,将读入的数据存入其中 fq.open(data.txt,ios::in);//以读入方式打开文件data.txt if(!fq)//检查文件是否打开成功 { cout文件data.txt打开失败!endl; return; } int n,m=0; while(!fq.

文档评论(0)

1亿VIP精品文档

相关文档