|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我是初学者,老师要求我们在 D盘中建立一个TXT文件,输入 任意名称和一门课的10次测验成绩。然后要用C++程序读取后原样输出到D盘另一个TXT文件,并且在末尾加上一个double类型的平均分。
我的文件内容: 小明 90 89 91 93 88 87 89 90 92 96.
我的程序是
#include<fstream>
#include<iostream>
using namespace std;
void add_plus_plus(ifstream& in_stream,ofstream& out_stream);
int main()
{
ifstream in;
ofstream out;
in.open("D:\\123123.txt");
out.open("D:\\123321.txt");
add_plus_plus(in,out);
in.close();
out.close();
return 0;
}
void add_plus_plus(ifstream& in_stream,ofstream& out_stream)
{
double sum=0,a,b;
int count=0;
while(in_stream>>a)
{
sum=sum+a;
count++;
}
b=sum/count;
out_stream<<b;
}
但是输出不出来 不知道哪里出错了 , 初学者嘛 。。。 给点帮助啦。
|
|