| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 559 人关注过本帖
标题:[求助]我的第一次系统程序.请指点我一下!谢谢了!
只看楼主 加入收藏
xianen20
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-12-30
收藏
 问题点数:0 回复次数:0 
[求助]我的第一次系统程序.请指点我一下!谢谢了!

长了些.不过运行可以通过的,但有些功能没法实现.(我的程序中3~5的功能显示不出数据来)我不知道在哪里出错了?
麻烦大家了.帮我指出,告诉我怎么修改.本人感激不尽了


#include "stdafx.h"
#include "iostream.h"
#include "stdlib.h"
#include "string.h"
#include "stdio.h"
const char null='\0';
static char *strsave(char *s) {
char *p;
p=new char[strlen(s)+1];
strcpy(p,s);
return p;
}
class student{ //学生类
public:
char *name;
char *stu_no;
char *sex;
char *banji;

student()
{
name=null;
stu_no=null;
sex=null;
banji=null;
}
student( char *name1,char *stu_no1,char *sex1,char *banji1)
{ name=strsave(name1);
stu_no=strsave(stu_no1);
sex=strsave(sex1);
banji=strsave(banji1);
}
~student()
{ delete []name;
delete []stu_no;
delete []sex;
delete []banji;
}
void print1()
{ cout<<"\n"<<"name:"<<name<<endl;
cout<<"stu_no:"<<stu_no<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"banji:"<<banji<<endl;
}
};
class kc{ //课程类
public:
char *yw_no;
char *yy_no;
char *sx_no;
char *zz_no;

kc(char *yw_no1, char *yy_no1,char *sx_no1,char *zz_no1)
{yw_no=strsave(yw_no1);
yy_no=strsave(yy_no1);
sx_no=strsave(sx_no1);
zz_no=strsave(zz_no1);}
~kc()
{ delete []yw_no;
delete []yy_no;
delete []sx_no;
delete []zz_no;
}
void print2()
{ cout<<"\n"<<"yw_no:"<<yw_no<<endl;
cout<<"yy_no:"<<yy_no<<endl;
cout<<"sx_no:"<<sx_no<<endl;
cout<<"zz_no:"<<sx_no<<endl;}
};
class score: public student, public kc{ // 学生成绩类
public:
int yw_cj;
int yy_cj;
int sx_cj;
int zz_cj;


score( char *name1,char *stu_no1,char *sex1,char *banji1,char*yw_no1,char *yy_no1,char *sx_no1,
char *zz_no1,int yw_cj1,int yy_cj1,int sx_cj1,int zz_cj1):student(name1, stu_no1,sex1,banji1),
kc(yw_no1, yy_no1, sx_no1, zz_no1)
{ yw_cj=yw_cj1;
yy_cj=yy_cj1;
sx_cj=sx_cj1;
zz_cj=zz_cj1;}

void print();
};

void score::print()
{ student::print1();
kc::print2();
cout<<"yw_cj:"<<yw_cj<<endl;
cout<<"yy_cj:"<<yy_cj<<endl;
cout<<"sx_cj:"<<sx_cj<<endl;
cout<<"zz_cj:"<<zz_cj<<endl;
}

int main()
{ char sel;char u[6],p[8];
char uu[6]={"admin"},pp[8]={"123456"};
int n=0;
cout<<"请输入用户名和密码:"<<endl;
cout<<"--------------------"<<endl;
cout<<"user:";
cin>>u;
cout<<"password:";
cin>>p;if(strcmp(uu,u)==0&&strcmp(pp,p)==0)
cout<<"******欢迎进入学生管理系统******"<<endl;
while(strcmp(uu,u)!=0||strcmp(pp,p)!=0)
{
cout<<"输入错误请重新输入"<<endl;
cout<<"请输入用户名和密码:"<<endl;
cout<<"user:";
cin>>u;
cout<<"password:";
cin>>p;
n++;

if(n==2)
{cout<<"对不起您的输入次数已经达到最大!"<<endl;exit(0);}}
cout<<"\n";

score a[10]={score("张三","0321335001","男","信管","001","002","003","004",75,85,65,70),
score("李四","0321335002","男","信管","001","002","003","004",56,85,69,80),
score("李明","0321335003","男","信管","001","002","003","004",68,75,86,83),
score("刘芳","0321335004","女","信管","001","002","003","004",84,65,59,78),
score("王乐","0321335005","女","信管","001","002","003","004",87,65,73,82),
score("高天","0321335010","男","电商","001","002","003","004",54,55,68,53),
score("李山","0321335012","男","电商","001","002","003","004",59,63,85,59),
score("王强","0321335013","男","电商","001","002","003","004",56,55,86,53),
score("刘欣","0321335014","女","电商","001","002","003","004",84,65,59,78),
score("乐乐","0321335015","女","电商","001","002","003","004",87,65,73,82),};

cout<<"*************** 学生管理系统 *************************"<<endl;
cout<<"1: 建立学生成绩表"<<endl;
cout<<"2: 添加一个学生信息"<<endl;
cout<<"3: 删除一个学生信息"<<endl;
cout<<"4: 修改学生信息"<<endl;
cout<<"5: 查找信息"<<endl;
cout<<"6: 信息统计"<<endl;
cout<<"7: 退出系统"<<endl;
cout<<"*******************************************************"<<endl;
cout<<"请输入操作:";
cin>>sel;
switch(sel)
{
case '1':{ cout<<"**********学生成绩表记录如下***********"<<endl;
for(int i=0;i<10;i++)
a[i].print();}; break;

case '2':{cout<<"********请输入要添加学生记录*********"<<endl;
cin>>a[10].name; cin>>a[10].stu_no; cin>>a[10].sex; cin>>a[10].banji;
cin>>a[10].yw_no; cin>>a[10].yy_no; cin>>a[10].sx_no; cin>>a[10].zz_no;
cin>>a[10].yw_cj; cin>>a[10].yy_cj; cin>>a[10].sx_cj; cin>>a[10].zz_cj;};break;

case '3':{cout<<"************进行删除操作************"<<endl; //删除成绩表中出现三门不及格的学生,显示符合条件学生
int n=0;char *p1="王强";
for(int c=0;c<10;c++)
if((a[c].sx_cj<60)&&strcmp(a[c].name,p1)==0)
{ n++;}
cout<<"************修改后的数据*************"<<endl;
if(n>=3)
for(int d=0;d<10;d++)
{if(strcmp(a[d].name,p1)>0||strcmp(a[d].name,p1)<0)
{ a[d].print(); cout<<"------------------------"<<endl;}
}}; break;
case '4':{cout<<"************进行修改操作************"<<endl; //根据学号,从表中找出数据进行修改
char *pp="0321335015";
for(int e=0;e<10;e++)
if(strcmp(a[e].stu_no,pp)==0)
{ cout<<"请输入修改后班级:";
cin>>a[e].banji;
a[e].print();
cout<<"-------------------------"<<endl;}}; break;
case '5':{cout<<"************进行查找操作************"<<endl; //按班级,课程进行成绩统计
student obj("乐乐","0321335015","女","电商");
cout<<"请输入要查找的人的姓名:"<<endl;
for(int g=0;g<10;g++)
if(strcmp(a[g].name,obj.name)==0)
a[g].print();
else
exit(0);
cout<<endl;
cout<<"请输入要查找的班级名:";
cin>>obj.banji;
for(int h=0;h<15;h++)
{if(strcmp(a[h].banji,obj.banji)==0) a[h].print();}};break;
case '6':{ cout<<"******进行统计操作******"<<endl;
char *p2="信管";char *p3="电商";
char *p4="001";char *p5="002";char *p6="003";char *p7="004"; int sum=0;
cout<<"******按班级统计成绩******"<<endl;
for(int i=0;i<10;i++)
if(strcmp(a[i].banji,p2)==0)
{ sum+=a[i].sx_cj;}
cout<<"信管的总成绩为:"<<sum<<endl;
for(int j=0;j<10;j++)
if(strcmp(a[j].banji,p3)==0)
{ sum+=a[j].yw_cj;}
cout<<"电商的总成绩为:"<<sum<<endl;
cout<<"******按课程统计成绩******"<<endl;
for(int i1=0;i1<10;i++)
if(strcmp(a[i1].yw_no,p4)==0)
{ sum+=a[i1].yw_cj;}
cout<<"语文的总成绩为:"<<sum<<endl;
for(int i2=0;i2<10;i++)
if(strcmp(a[i2].yy_no,p5)==0)
{ sum+=a[i2].yy_cj;}
cout<<"英语总成绩为:"<<sum<<endl;
for(int i3=0;i3<10;i++)
if(strcmp(a[i3].sx_no,p4)==0)
{ sum+=a[i3].sx_cj;}
cout<<"数学的总成绩为:"<<sum<<endl;
for(int i4=0;i4<10;i++)
if(strcmp(a[i4].zz_no,p4)==0)
{ sum+=a[i4].zz_cj;}
cout<<"政治的总成绩为:"<<sum<<endl;};break;

case '7':{exit(0);};break;
}

return 0;
}

搜索更多相关主题的帖子: 系统程序 
2006-01-13 13:58
快速回复:[求助]我的第一次系统程序.请指点我一下!谢谢了!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.055371 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved