主题:怎样用语言编写一个学生管理系统?
珠穆朗玛峰
[专家分:0] 发布于 2005-10-11 18:30:00
怎样用C++语言编写一个学生管理系统?请高手指点.
回复列表 (共14个回复)
沙发
ryowu [专家分:6470] 发布于 2005-10-12 12:03:00
你的问题难以用简短的文字回答正如你的名字一样难以用米尺来量……
板凳
huyufan [专家分:0] 发布于 2007-03-14 16:54:00
using System;
using System.IO;
using System.Text;
namespace @case
{
//学生成绩类
public class StuScoreSem2
{
int eng; //英语
int math; //数学
int sport; //体育
int datastructure; //数据结构
int operatingSystem; //操作系统
//构造器
public StuScoreSem2()
{
this.eng = 0;
this.math = 0;
this.sport = 0;
this.datastructure = 0;
this.operatingSystem = 0;
}
3 楼
huyufan [专家分:0] 发布于 2007-03-14 16:54:00
//构造器
public StuScoreSem2(int eng, int math, int sport, int datastructure, int operatingSystem)
{
this.eng = eng;
this.math = math;
this.sport = sport;
this.datastructure = datastructure;
this.operatingSystem = operatingSystem;
}
//英语属性
public int Eng
{
get
{
return eng;
}
set
{
this.eng = value;
}
}
4 楼
huyufan [专家分:0] 发布于 2007-03-14 16:54:00
//数学属性
public int Math
{
get
{
return math;
}
set
{
this.math = value;
}
}
//体育属性
public int Sport
{
get
{
return sport;
}
set
{
this.sport = value;
}
}
//数据结构属性
public int Datastucture
{
get
{
return datastructure;
}
set
{
this.datastructure = value;
}
}
5 楼
huyufan [专家分:0] 发布于 2007-03-14 16:56:00
/操作系统属性
public int OperatinSystem
{
get
{
return operatingSystem;
}
set
{
this.operatingSystem = value;
}
}
}
//学生信息类
public class StuInfo
{
int id; //学号
string name; //姓名
string sex; //性别
int age; //年龄
//构造器
public StuInfo()
{
this.id = 0;
this.name = "";
this.sex = "";
this.age = 0;
}
//构造器
public StuInfo(int id, string name, string sex, int age)
{
this.id = id;
this.name = name;
this.sex = sex;
this.age = age;
}
//学号属性
public int Id
{
get
{
return id;
}
set
{
this.id = value;
}
}
//年龄属性
public string Name
{
get
{
return name;
}
set
{
this.name = value;
}
}
//性别属性
public string Sex
{
get
{
return sex;
}
set
{
this.sex = value;
}
}
//年龄属性
public int Age
{
get
{
return age;
}
set
{
this.age = value;
}
}
}
//学生类
public class Student
{
StuInfo info; //学生信息
StuScoreSem2 scores; //学生成绩
int sum; //总分
int average; //平均分
//构造器
public Student()
{
this.info = "";
this.scores = 0;
this.sum = 0;
this.average = 0;
}
//构造器
public Student(StuInfo info, StuScoreSem2 scores)
{
this.info = info;
this.scores = scores;
}
//学生信息属性
public StuInfo Info
{
get
{
return info;
}
set
{
this.info = value;
}
}
6 楼
huyufan [专家分:0] 发布于 2007-03-14 16:57:00
//学生成绩属性
public StuScoreSem2 Scores
{
get
{
return scores;
}
set
{
this.scores = value;
}
}
//总分属性
public int Sum
{
get
{
return sum;
}
set
{
this.sum = value;
}
}
//平均分属性
public int Average
{
get
{
return average;
}
set
{
this.average = value;
}
}
//计算总分
public void ComputeSum()
{}
//计算平均分
public void ComputeAverage()
{ }
}
7 楼
huyufan [专家分:0] 发布于 2007-03-14 16:57:00
public class Process
{
Student[] students;
public Student[] Students
{
get
{
return students;
}
set
{
this.students = value;
}
}
public Process(Student[] students)
{
this.students = students;
}
//按总分排序
public void SortBySum()
{}
//按平均分排序
public void SortByAverage()
{ }
//按某科成绩排序
public void SortBySubject(string subject)
{ }
//按学生的某个信息进行查找,如果有返回该学生的信息,否则返回空
public Student SearchByInfo(string info)
{ }
//按总分输出学生信息
public void OutputInfoBySum()
{ }
//按平均分输出学生信息
public void OutputInfoByAverage()
{ }
//按学生的某科成绩输出学生信息
public void OutputInfoBySubject(string subject)
{ }
}
8 楼
huyufan [专家分:0] 发布于 2007-03-14 16:58:00
class Program
{
static void Main(string[] args)
{
//创建学生信息数组和学生成绩数组
stuInfo[] info = new stuInfo[50];
stuScoreSem2[] scores = new stuScoreSem2[50];
Student[] student = new Student[50];
int i = 0;
int j = 0;
//创建一个输入流进行读输入文件
FileStream input = new FileStream("..//..//..//stuinfo.txt", FileMode.Open, FileAccess.Read);
//创建一个输入字符流
StreamReader reader = new StreamReader(input, Encoding.Default);
//创建一个输出流和输出文件保存输出信息
// FileStream output = new FileStream("..//..//..//stuoutput.txt", FileMode.Create,FileAccess.ReadWrite);
//创建一个输出字符流
//StreamWriter writer = new StreamWriter(output, Encoding.Default);
9 楼
huyufan [专家分:0] 发布于 2007-03-14 16:59:00
reader.ReadLine();
string str = reader.ReadLine();
while (str != null)
{
string[] split = str.Split(new char[] { ' ', '\t' });
info[i] = new stuInfo();
scores[i] = new stuScoreSem2();
foreach (string s in split)
{
if (s != "" && s.Trim() != "")
{
switch (j)
{
case 0:
info[i].Id = Int32.Parse(s);
++j;
break;
case 1:
info[i].Name = s;
++j;
break;
case 2:
info[i].Sex = s;
++j;
break;
case 3:
info[i].Age = Int32.Parse(s);
++j;
break;
case 4:
scores[i].Eng = Int32.Parse(s);
++j;
break;
case 5:
scores[i].Math = Int32.Parse(s);
++j;
break;
case 6:
scores[i].Sport = Int32.Parse(s);
++j;
break;
case 7:
scores[i].Datastucture = Int32.Parse(s);
++j;
break;
case 8:
scores[i].OperatinSystem = Int32.Parse(s);
++j;
break;
default:
break;
}
}
}
10 楼
huyufan [专家分:0] 发布于 2007-03-14 16:59:00
student[i] = new Student(info[i], scores[i]);
j = 0;
++i;
str = reader.ReadLine();
}
reader.Close();
//writer.Close();
input.Close();
//output.Close();
}
}
}
我来回复