现在的位置: 首页 > 综合 > 正文

第十一周项目5-3-体验读入文档操作3

2014年11月23日 ⁄ 综合 ⁄ 共 797字 ⁄ 字号 评论关闭
/*                           
*程序的版权和版本声明部分:                           
*Copyright(c)2013,烟台大学计算机学院学生                           
*All rights reserved.                           
*文件名称:                           
*作者:田成琳                           
*完成日期:2013年 11月1 日                           
*版本号:v1.0                           
*对任务及求解方法的描述部分:                           
*输入描述:    
*问题描述:体验文档读入操作   
*程序输出:   
*问题分析:                           
*算法设计:                           
*/    
我的程序:
#include <iostream>

#include<fstream>

using namespace std;

int main()
{
    int a,max=-999,min=999,n,i=0,b=0,c=0,d=0,e=0;
    double sum=0,ave;
    ifstream infile("D:\\english.DAT",ios::in);
    if(!infile)
    {
        cerr<<"open error!"<<endl;
    }
    for(n=1;n<=10000;n++)
    {
        infile>>a;
        if(a>max)
        max=a;
        sum+=a;
        if(a<min)
        min=a;
        if(a>=90)
        {
            i++;
        }
        else if(a>=80&&a<90)
        {
            b++;
        }
        else if(a>=70&&a<80)
        {
            c++;
        }
        else if(a>=60&&a<70)
        {
            d++;
        }
        else if (a<60)
        {
            e++;
        }
    }
    infile.close();
    ave=sum/10000;
    cout<<"最高成绩是:"<<max<<endl;
    cout<<"最低成绩是:"<<min<<endl;
    cout<<"平均成绩是:"<<ave<<endl;
    cout<<"优秀的人数为:"<<i<<endl;
    cout<<"良好的人数为:"<<b<<endl;
    cout<<"中等的人数为:"<<c<<endl;
    cout<<"及格的人数为:"<<d<<endl;
    cout<<"不及格的人数为:"<<e<<endl;
    return 0;
}

运行结果:

心得体会:略。

抱歉!评论已关闭.