#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
string line;
int head=0,count=0,num;
float math,english,sum_math=0,sum_english=0,average;
ifstream ifs("chengji.txt");
if(!ifs) return -1;
ofstream ofs("chengji_result.txt");
if(!ofs) return -2;
while(getline(ifs,line))
{
istringstream is(line);
if(head==0)
{
//跳过第一行的表头
head=1;
continue;
}
is>>num>>math>>english;
if(count==0)
{
ofs<<"学生编号\t平均成绩"<<endl;
}
ofs<<num<<"\t"<<(math+english)/2<<endl;
sum_math+=math;
sum_english+=english;
count++;
}
if(count>0)
{
ofs<<endl;
ofs<<"数学平均成绩:"<<sum_math/count<<endl;
ofs<<"英语平均成绩:"<<sum_english/count<<endl;
}
ifs.close();
ofs.close();
return 0;
没有合适的资源?快使用搜索试试~ 我知道了~
Jump-too-much-of-a-line.rar_Too Much
共1个文件
txt:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 29 浏览量
2022-09-22
22:45:18
上传
评论
收藏 540B RAR 举报
温馨提示
C++读取txt文件时,能够跳过文件的第一行而从第二行开始读取文件内容!!!!
资源推荐
资源详情
资源评论
收起资源包目录
Jump-too-much-of-a-line.rar (1个子文件)
Jump too much of a line.txt 850B
共 1 条
- 1
资源评论
钱亚锋
- 粉丝: 88
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功