#include
#include
using namespace std;
template
int getArrayLen(T& array)
//使用模板定义一个函数getArrayLen,该函数将返回数组array的长度
{
return (sizeof(array) / sizeof(array[0]));
}

class Student{
public:
char name[20];
int id;
int score;
public:
Student(int i = 0, char* c="", int s= 0)
{
id = i;
strcpy(name,c);
score = s;
}
Student& operator = (const Student& rhs )
{
id = rhs.id;
strcpy(name,rhs.name);
score = rhs.score;
return *this;
}
void gets()
{
cin>>name>>id>>score;
}
void print()
{
cout<<"name:\t"<<name<<"\tid:\t"<<id<<"\tscore:\t"<<score<<endl;
}
} ;

void rank(int n,Student a[])//排序函数
{
int i, j; Student t;
for(i = 0 ; i < n ; i++ )
for(j = i + 1; j < n -1 ; j ++)
{
if(a[i].score < a[j].score){t = a[i]; a[i] = a[j] ;a[j] =
t;}
}
}

int average(Student a[],int n)//求平均数
{
int sum = 0,average;
for(int i = 0 ; i < n ; i++)
sum+=a[i].score;
average = sum / n;
return average;
}
void input(Student s[],int n)//输入信息的函数
for(int i = 0 ; i < n ; i++)
   s[i].gets();
}
void output(Student s[],int n)//输出信息的函数
for(int i = 0 ; i < n ; i++)
     
s[i].print();
}

//主函数
int main()
{
Student class1[10];//十个人的信息
cout<<"******************************************"<<endl;
cout<<"please enter name id score:"<<endl;
input(class1,10);
cout<<"name    
     
   id  
     
    score
 :"<<endl;
cout<<"******************************************"<<endl;
output(class1,10);
cout<<"******************************************"<<endl;
cout<<"this class average score
is:"<<average(class1,4)<<endl;
cout<<"******************************************"<<endl;
    rank(10,class1);
output(class1,4);//输出前四的信息
return 0;
}

C++学生信息处理的更多相关文章

  1. JavaWeb -学生信息管理实践(JDBC+web+三层架构+DBUtil构造思路)

    前言: 1 该程序使用动态web项目 2 该程序使用SQL server需导入对应包( 具体可看前篇----JDBC的使用) 3 三层架构思想: ①表示层 前台:jsp/html等 作为前台与用户交互 ...

  2. 第一次写C语言小程序,可以初步理解学生成绩管理系统的概念

    1 成绩管理系统概述 1.1  管理信息系统的概念  管理信息系统(Management Information Systems,简称MIS),是一个不断发展的新型学科,MIS的定义随着科技的进步也在 ...

  3. 阿里云学生优惠Windows Server 2012 R2安装IIS,ftp等组件,绑定服务器域名,域名解析到服务器,域名备案,以及安装期间错误的解决方案

     前言: 这几天终于还是按耐不住买了一个月阿里云的学生优惠.只要是学生,在学信网上注册过,并且支付宝实名认证,就可以用9块9的价格买阿里云的云服务ECS.确实是相当的优惠. 我买的是Windows S ...

  4. 【IOS开发笔记02】学生管理系统

    端到端的机会 虽然现在身处大公司,但是因为是内部创业团队,产品.native.前端.服务器端全部坐在一起开发,大家很容易做零距离交流,也因为最近内部有一个前端要转岗过来,于是手里的前端任务好像可以抛一 ...

  5. sql面试题(学生表_课程表_成绩表_教师表)

    原帖链接:http://bbs.csdn.net/topics/280002741 表架构 Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程 ...

  6. 数据结构(c语言)之学生信息管理系统

    程序思维导图 代码表示(代码参考:长春大学-牛言涛老师) 如有错误请指出欢迎交流 #include<stdio.h> #include<malloc.h>//动态存储分配函数头 ...

  7. mysql练习题-查询同时参加计算机和英语考试的学生的信息-遁地龙卷风

    (-1)写在前面 文章参考http://blog.sina.com.cn/willcaty. 针对其中的一道练习题想出两种其他的答案,希望网友给出更多回答. (0) 基础数据 student表 +-- ...

  8. 丰富“WinForms” 的一个别样"项目"(学生管理)

    一个别样的WinForms项目,他并没多么的新颖,但是它的用处确实有点多,或许会有你需要的地方:如果你对WinForms中那么多控件无法把握,又或者是你根本就不懂,那我觉得你应该好好看看,如果一个人的 ...

  9. 设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。

    一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...

随机推荐

  1. for循环删除list中多个元素出现的误区

    错误的做法是: for(int i= 0;i<list.size();i++) 因为在你删除元素的同时list.size()也在变小,这样就会照成越界. 正确做法:因为要删除list里面的多个的 ...

  2. json遍历,List<Map<String,Object>>遍历

    js怎样给input对象追加属性,如disabled $(":textbox").attr({"disabled":true}); List<Map< ...

  3. Java快速IO(ACM)必备

    en.... 无非用到的是 1. new Scanner(System.in); 2.new BUfferReader(new InputStreamReader(System.in); 3.Syst ...

  4. Github如何在Linux系统下创建本地仓库

    一.电脑上安装 Git Ubuntu安装GIt:  apt-get install git 查看版本信息:    git version 配置Git用户信息  输入: git config --glo ...

  5. CodeForces - 124B-Permutations(DFS)

    You are given n k-digit integers. You have to rearrange the digits in the integers so that the diffe ...

  6. Go语言基础之5--数组(array)和切片(slince)

    一.数组(array) 1.1 数组定义 1)含义: 数组是同一类型的元素集合. 数组是具有固定长度并拥有零个或者多个相同数据类型元素的序列. 2)定义一个数组的方法: var 变量名[len] ty ...

  7. getter与setter

    var obj = { get a() { return 2; }, get c() { return 34 } } Object.defineProperty( obj, 'b', { get: f ...

  8. linux 6 安装 使用 XtraBackup

    帮助文档:https://www.cnblogs.com/imweihao/p/7290026.html ---Yum安装 官网地址:https://www.percona.com/doc/perco ...

  9. SQL智能提示插件——SQLPrompt

    1.安装SQLPrompt,直接点击下一步即可,然后打开SQL Server 在菜单栏找到SQLPrompt选项注册该软件 2.先断开网络,然后运行注册机,将注册吗复制到序列号的地方,将两个勾选的复选 ...

  10. Android NDK开发 Jni中Debug(三)

    下载LLDB 配置Android Native - Debugger 调式结果如下 #include <jni.h> #include <string.h> #include& ...