菜鸟问题~~~(等级太低 只能给这么多~~~~可以在给)
高手看看~~~刚弄的学生管理系统bug太多
就是在录入数据后 在调用查询海曙是没有值~~?高手看看 我知道我的问题很菜但是我现了号称时间也不知道问题处在那里 ~~~分不够可以再给 本人基础太差 希望说明白点~~
在这里先谢谢了~~~// student.cpp: implementation of the Cstudent class.
//
//////////////////////////////////////////////////////////////////////
#include "student.h "
#include <iostream>
using namespace std;
void pp();
//#include "stdafx.h "
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Cstudent::Cstudent()
{
memset(Name,0,100*10);
memset(ID,0,100*11);
memset(sex,0,100*3);
for(int i=0;i <100;i++)
cpp[i]=eng[i]=math[i]=0;
n++;
}
//////////////////////////////////////////////////////////////////////////////
Cstudent::~Cstudent()
{
n--;
}
////////////////////////////////////////////////////////////////////////////
void read()
{
cout < < " ★★★★★★★★★★★★★★★★★★★★★★★★★★★ " < <endl;
cout < < " ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ " < <endl;
cout < < "☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ " < <endl;
cout < < " ** ★★★ § ① --帮助 § ★★★ ** " < <endl;
cout < < " ** ★★★ § ② --输入学生信息 § ★★★ ** " < <endl;
cout < < " ** ★★★ § ③ --查询信息 § ★★★ ** " < <endl;
cout < < " ** ★★★ § ④ --排序 § ★★★ ** " < <endl;
cout < < " ** ★★★ § ⑤ --修改 § ★★★ ** " < <endl;
cout < < " ** ★★★ § ⑥ --统计及格和优秀人数 § ★★★ ** " < <endl;
cout < < " ** ★★★ § ⑦ --退出系统 § ★★★ ** " < <endl;
cout < < "☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ " < <endl;
}
///////////////////////////////////////////////////////////////////////////////////////①②③④⑤⑥⑦
int Cstudent::n=0;
void Cstudent::putStd()
{ int i;
{cout < < "请输入学生姓名 " < <endl;
cin> > Name[n];
cout < < "姓名 " < <Name[n];
cout < < "请输入学生学号 " < <endl;
cin> > ID[n];
cout < < "学号 " < <ID[n];
cout < < "请输入学生性别 " < <endl;
cin> > sex[n];
cout < < "性别 " < <sex[n] < <endl;
a1:cout < < "请输入学生c++成绩 " < <endl;
cin> > cpp[n];
if(cpp[n]> =0&&cpp[n] <=100){cout < < "c++成绩 " < <cpp[n] < <endl;}
else{cout < < "成绩应该在0~100之间,请重新输入: " < <endl;goto a1;}
a2:cout < < "请输入学生数学成绩: " < <endl;
cin> > math[n];
if(math[n]> =0&&math[n] <=100){cout < < "数学成绩 " < <math[n] < <endl;}
else{cout < < "成绩应该在0~100之间,请重新输入: " < <endl;goto a2;}
a3:cout < < "请输入学生英语成绩 " < <endl;
cin> > eng[n];
if(eng[n]> =0&&eng[n] <=100){cout < < "英语 " < <eng[n] < <endl;}
else{cout < < "成绩应该在0~100之间,请重新输入: " < <endl;goto a3;}
n++;
cout < < "姓名 " < <Name[n-1] < < " " < < "学号 " < <ID[n-1] < < "性别 " < <sex[n-1] < < " " < < "c++成绩 " < <cpp[n-1] < < " "
< < "数学成绩 " < <math[n-1] < < " " < < "英语成绩 " < <eng[n-1] < <endl;
}
cout < < "①继续进行输入:\n②返回主菜单: " < <endl;
cin> > i;
if(i==1){putStd();}
else { pp();}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
void Cstudent::coutStd()
{
for(int i=0;i <n;i++)
{
cout < < "姓名 " < <Name[i] < < " " < < "学号 " < <ID[i] < < "性别 " < <sex[i] < < " " < < "c++成绩 " < <cpp[i] < < " "
< < "数学成绩 " < <math[i] < < " " < < "英语成绩 " < <eng[i] < <endl;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Cstudent::selectName()
{
char op[11];
memset(op,0,11);
cout < < "您要查找的姓名: ";
cin> > op;
for(int i=0;i <n;i++)
{
if(strcmp(Name[i],op)==0)
{
cout < < "姓名 " < <Name[i] < < " " < < "学号 " < <ID[i] < < "性别 " < <sex[i] < < " " < < "c++成绩 " < <cpp[i] < < " "
< < "数学成绩 " < <math[i] < < " " < < "英语成绩 " < <eng[i] < <endl;
}
else {cout < < "没有你查找的内容,请从新选择: " < <endl;}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Cstudent::selectID()
{
char op[100];
memset(op,0,11);
cout < < "您要查找的学号: ";
cin> > op;
for(int i=0;i <n;i++)
{
if(strcmp(ID[i],op)==0)
{
cout < < "姓名 " < <Name[i] < < " " < < "学号 " < <ID[i] < < "性别 " < <sex[i] < < " " < < "c++成绩 " < <cpp[i] < < " "
< < "数学成绩 " < <math[i] < < " " < < "英语成绩 " < <eng[i] < <endl;
}
else {cout < < "没有你查找的内容,请从新选择: " < <endl;}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Cstudent::selectSex()
{
char op[3];
memset(op,0,3);
cout < < "您要查找的性别: ";
cin> > op;
for(int i=0;i <n;i++)
{
if(strcmp(sex[i],op)==0)
{
cout < < "姓名 " < <Name[i] < < " " < < "学号 " < <ID[i] < < "性别 " < <sex[i] < < " " < < "c++成绩 " < <cpp[i] < < " "
< < "数学成绩 " < <math[i] < < " " < < "英语成绩 " < <eng[i] < <endl;
}
else {cout < < "没有你查找的内容,请从新选择: " < <endl;}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Cstudent::tongji()
{
int Jcpp=0,Jmath=0,Jeng=0;
for(int i=0;i <n;i++)
{
if(cpp[i]> =60)
{Jcpp++;}
if(math[i]> =60)
{Jmath++;}
if(eng[i]> =60)
{Jeng++;}
}
cout < < "c++及格人数: " < <Jcpp < < "数学及格人数: " < <Jmath < < "英语及格人数: " < <Jeng < <endl;
}
/////////////////////////////////////////////////////////////////////////////////////////
void Cstudent::xiugai()
{
char op[11];
memset(op,0,11);
cout < < "您要查找的学号: ";
cin> > op;
for(int i=0;i <n;i++)
{
if(strcmp(op,ID[i])==0)
{
cout < <Name[i] < < " " < <ID[i] < < " " < <sex[i] < < " " < <cpp[i] < < " " < <math[i] < < " " < <eng[i] < <endl;
cout < < "please update the student " < <endl;
cout < < "请输入学生姓名: " < <endl;
cin> > Name[i];
cout < < "请输入学生学号: " < <endl;
cin> > ID[i];
cout < < "请输入学生性别: " < <endl;
cin> > sex[i];
cout < < "请输入学生c++成绩: " < <endl;
cin> > cpp[i];
cout < < "请输入学生数学成绩: " < <endl;
cin> > math[i];
cout < < "请输入学生英语成绩: " < <endl;
cin> > eng[i];
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void chaxun()
{
Cstudent std2;
int index1=0,index2=0;
cout < < "1:按学号查找\n2:按姓名查找\n3按性别查找\n4返回主菜单 " < <endl;
cin> > index1;
if(index1==4)
{ read(); }
else
{
switch(index1)
{
case 1:std2.selectID();break;
case 2:std2.selectName();break;
case 3:std2.selectSex(); break;
default:{cout < < "输入有误,请重新输入: ";
cin> > index2;
chaxun();
};
}
}
}
[解决办法]
打包工程发到我邮箱 附带如何配置的数据库
final.wei@gmail.com
[解决办法]
- -~
[解决办法]
up!
[解决办法]
好强
[解决办法]
老兄啊 你的Cstudent类呢
把程序给齐全了罗……………………!!
[解决办法]
贴全一点嘛,看看
[解决办法]
你没写清楚出什么大问题,但是我就下面你书写上的问题交流一下:
strcmp(ID[i],op) == 0 //如果op输入的数字超过一个你这个很明显就错了吧,建议strcmp(ID , op ) == 0
int Cstudent::n=0; //这个不知道你是什么意思,n好象应该是一个函数吧,函数怎么没有括号呢?把0赋给他有什么作用? int Cstudent::n()=0
Cstudent::~Cstudent() //这个是在运行程序结束的时候才执行的
{
n--;
}
cin> > Name[n]; //这个你是输入姓名,但是你后面加了括号也就是只能输出一个字符了,应该这样就对了 cin > > Name ;
//最后建议你在写一个结构体,这样应该更好一些,一面有我写的一个顺序表的操作,里面的内容你可以看一下,应该对你有所启发..
//C++(运行通过)
/ "list.h " 类定义和类成员函数的实现,注释很详细
//The list operand
#include <iostream>
using namespace std ;
//definition class list
template < classT > //declaration template
classsq_List
{
private:
intsize ;//List space size
intlen ; //List length
T*pointer ;
public:
sq_List( int ) ;
voidsq_insert_List( intpos , Tvalue ) ;
voidsq_del_List( intpos ) ;
intsq_flag_List() ;
voidsq_print_List() ;
} ;
//initial structure function
template < classT >
sq_List < T > ::sq_List( intnum )
{
size = num ;
pointer = newT[ size ] ;//pointer to the List initial address
len = 0 ; //List length initial zero
return ;
}
//insert function definition
template < classT >
voidsq_List < T > ::sq_insert_List( intpos , T value )
{
if( len == size )
{
cout < < "The List has been full , your operator will result in overflow! " < < endl ;
return;
}
if( pos > len )
pos = len + 1 ;
if( pos < 1 )
pos = 1 ;
for( inti = len ; i > = pos ; --i )
{
pointer[ i ] = pointer[ i - 1 ] ;
}
pointer[ pos - 1 ] = value ;
len++ ;
return;
}
//delete function definition
template < classT >
voidsq_List < T > ::sq_del_List( intpos )
{
if( len == 0 )
{
cout < < "The List has been empty , your operator will result in under flow! " < < endl ;
return;
}
if( pos < 1 || pos > len )
{
cout < < "This elements not found in the List! " < < endl ;
return;
}
for( inti = pos ; i < len ; ++i )
{
pointer[ i - 1 ] = pointer[ i ] ;
}
len-- ;
return;
}
//present List estate flag
template < classT >
intsq_List < T > ::sq_flag_List()
{
if( len == size )
return-1 ; //The List full return-1
if( len == 0 )
return0 ; //The List empty return0
return1 ;//natural instance return1
}
//print function definition
template < classT >
voidsq_List < T > ::sq_print_List()
{
cout < < "The List length is: " < < len < < endl ; //output List length
for( inti = 0 ; i < len ; ++i )
{
cout < < " " < < pointer[ i ] ;
}
cout < < endl ;
}
// "list.cpp "
#include "list.h "
intmain()
{
sq_List < int > list( 10 ) ;
list.sq_insert_List( 0 , 2 ) ;
list.sq_insert_List( 1 , 3 ) ;
list.sq_insert_List( 2 , 5 ) ;
cout < < "The first output: " < < endl ;
list.sq_print_List() ;
if( list.sq_flag_List() != 0 )
list.sq_del_List( 1 ) ;
else
{
cout < < "under flow! " < < endl ;
return0 ;
}
list.sq_del_List( 2 ) ;
cout < < "The second output: " < < endl ;
list.sq_print_List() ;
system( "pause ") ;
return0 ;
}
希望能对你有所帮助!!!!!!!!!