/*
* Copyright (c) 2012, 烟台大学计算机学院
* All rights reserved.
* 文件名称:test.cpp
* 作者:纪子龙
* 完成日期:2012 年12月26日
* 版本号:v1.0
*
* 输入描述:无
* 问题描述:将数据“写入、输出”到文件中
* 程序输出:将数据输出
* 问题分析:
* 算法设计:略
*/
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
int a;
ofstream outfile("num.txt",ios::out);
if(!outfile){
cerr<<"open error!"<<endl;
exit(1);
}
for(int i=0;i<10;i++){
cin>>a;
outfile<<a<<endl;
}
outfile.close();
cout<<"处理完毕,请打开文件查看结果!"<<endl;
return 0;
}
运行结果: