获得奖学金的名单
来源:互联网 发布:晋城网络电视台 编辑:程序博客网 时间:2024/04/28 01:32
*/ * 程序的版权和版本声明部分 *Copyright (c)2013, 烟台大学计算机学院学生 * All rightsreserved. *文件名称: array.cpp * 作 者:杨绍宁 * 完成日期: 2012 年3 月13 日 * 版本号: v1.0 * * 输入描述:已经在程序初始化中 *问题描述:将学生成绩信息存储在结构体数组中,对结构体并输出排序 *输出:按C++降序和按学号升序排列后的学生成绩单 */ #include <fstream> //操作文件必写 #include <iostream>using namespace std;struct Student{char num[300];char name[300];int cpp;int math;int english;int score;};int main(){struct Student student[300];int num=0,i,j;Student t[1]; ifstream infile("score.txt",ios::in);if(!infile){cout<<"open error"<<endl;exit(1);}while(!infile.eof())//当文件没有达到结尾的时候,继续读入。 { infile>>student[num].num>>student[num].name>>student[num].cpp>>student[num].math>>student[num].english; ++num; } infile.close();for(i=0;i<num;i++){student[i].score=student[i].cpp+student[i].math+student[i].english;}for(i=0;i<num;i++){ for(j=0;j<num-i;j++) if(student[j].score<student[j+1].score){ t[0]=student[j]; student[j]=student[j+1]; student[j+1]=t[0]; } }int n;for(i=0;i<num;i++){if(student[i].cpp>=60&&student[i].math>=60&&student[i].english>=60){++n;}}for(n=0;n<=30;n++)cout<<student[n].name<<" ";return 0;}
结果:
感受:获奖好!!!
- 获得奖学金的名单
- 项目三 奖学金名单
- nyoj60谁获得的奖学金最高
- 谁获得最高奖学金
- 谁获得最高奖学金
- 谁获得最高奖学金
- 奖学金(谁获得了最高奖学金)
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 数据科学家-为大数据时代做好准备
- Java Socket
- C语言函数 fopen
- 开发《娃娃遇到兵》过程中用到的资料
- apache和tomcat区别
- 获得奖学金的名单
- struts1开发入门教程
- 黑马程序员 笔记(五)——面向对象(概述、类与对象、封装、构造函数、this)
- jQuery formValidator表单验证插件是什么?
- python笔记之字符串
- systemtap原理及使用
- Processing.js快速入门--javascript开发版
- SmartOS 与 Linux 不同点总结
- android 启动子活动返回数据