首页编程学生管理系统源代码?学生信息管理系统最简单源代码。

学生管理系统源代码?学生信息管理系统最简单源代码。

编程之家2023-11-05202次浏览

大家好,今天小编来为大家解答学生管理系统源代码这个问题,学生信息管理系统最简单源代码。很多人还不知道,现在让我们一起来看看吧!

学生管理系统源代码?学生信息管理系统最简单源代码。

学生信息管理系统源代码

void Sort(student*&head, char type,char maxOrMin)

{

/*参数说明:

type=='1'按语文排列

type=='2'按数学排列

type=='3'按英语排列

学生管理系统源代码?学生信息管理系统最简单源代码。

type=='4'按总分排列

type=='5'按平均分排列

type=='6'按座号排列

*/

student*pHead,*pH;

pHead=pH=head;

学生管理系统源代码?学生信息管理系统最简单源代码。

int len=GetLength(head);

float*array=new float[len];

int i;

int x=0;

float num=0;

while(head)

{

Count(head);

if(type=='1')

{

num=head->chinaNum;

}

else if(type=='2')

{

num=head->mathNum;

}

else if(type=='3')

{

num=head->englishNum;

}

else if(type=='4')

{

num=head->result;

}

else if(type=='5')

{

num=head->average;

}

else if(type=='6')

{

num=head->num;

}

array[x]=num;

x++;

head=head->next;

}

head=pHead;

if(maxOrMin=='1')

{

for( i=1; i<len; i++)

{

for(int j=0; j<len-i; j++)

{

if(array[j]<array[j+1])

{

float num;

num=array[j];

array[j]=array[j+1];

array[j+1]=num;

}

}

}

}

else

{

for( i=1; i<len; i++)

{

for(int j=0; j<len-i; j++)

{

if(array[j]>array[j+1])

{

float num;

num=array[j];

array[j]=array[j+1];

array[j+1]=num;

}

}

}

}

int pos=1;

for(i=0; i<len; i++)

{

head=pHead;

while(head)

{

if(type=='1')

{

num=head->chinaNum;

}

else if(type=='2')

{

num=head->mathNum;

}

else if(type=='3')

{

num=head->englishNum;

}

else if(type=='4')

{

num=int(head->result);

}

else if(type=='5')

{

num=int(head->average);

}

else if(type=='6')

{

num=int(head->num);

}

int n=0;

if(int(array[i])==int(num))

{

if(int(array[i])!=int(array[i+1]))

{

if(n==0)

{

n=pos;

}

head->pos=pos;

pos++;

}

else

{

head->pos=n;

}

}

head=head->next;

}

}

head=pH;

delete []array;

}

void Count(student*&head)

{

head->result=head->chinaNum+head->englishNum+head->mathNum;

head->average=head->result/3;

}

void DeleteAll(student*&head)

{

student*cp,*np;

cp=head;

while(cp)

{

np=cp->next;

delete cp;

cp=np;

}

head=NULL;

}

void ChaXun(string str,student*head)

{

Sort(head,'4','1');

cout<<"欢迎使用查询功能"<<endl<<endl;

cout<<"请输入你要按什么查询 1->一般查询 2->查找最多 3->查找最少"<<endl;

string s;

cin>>s;

while(s[0]!='1'&&s[0]!='2'&&s[0]!='3')

{

cout<<"你输入错误,请重新输入."<<endl;

cin>>s;

}

if(s[0]=='1')

{

cout<<"按什么查询?"<<endl;

cout<<"1->姓名 2->座号 3->语文成绩 4->数学成绩"

<<"5->英语成绩 6->总分 7->平均分 8->排名"<<endl;

cin>>str;

while(str[0]!='1'&& str[0]!='2'&&

str[0]!='3'&& str[0]!='4'&&

str[0]!='5'&& str[0]!='6'&&

str[0]!='7'&& str[0]!='8')

{

cout<<"你输入错误,请重新输入."<<endl;

cin>>str;

}

char findStr[30];

cout<<"请输入要查找的关键字或关键数:"<<endl;

cin>>findStr;

switch(str[0])

{

case'1':

Find(head,findStr,'1');

break;

case'2':

Find(head,findStr,'2');

break;

case'3':

Find(head,findStr,'3');

break;

case'4':

Find(head,findStr,'4');

break;

case'5':

Find(head,findStr,'5');

break;

case'6':

Find(head,findStr,'6');

break;

case'7':

Find(head,findStr,'7');

break;

case'8':

Find(head,findStr,'8');

break;

}

}

else if(s[0]=='2')

{

cout<<"请输入要按什么查询?"<<endl;

cout<<"1->语文成绩 2->数学成绩"

<<"3->英语成绩 4->总分 5->平均分 6->排名"<<endl;

string s;

cin>>s;

switch(s[0])

{

case'1':

FindMaxOrMin(head,'1','1');

break;

case'2':

FindMaxOrMin(head,'2','1');

break;

case'3':

FindMaxOrMin(head,'3','1');

break;

case'6':

FindMaxOrMin(head,'6','1');

break;

case'5':

FindMaxOrMin(head,'5','1');

break;

default:

FindMaxOrMin(head,'4','1');

break;

}

}

else if(s[0]=='3')

{

cout<<"请输入要按什么查询?"<<endl;

cout<<"1->语文成绩 2->数学成绩"

<<"3->英语成绩 4->总分 5->平均分 6->排名"<<endl;

string s;

cin>>s;

switch(s[0])

{

case'1':

FindMaxOrMin(head,'1','2');

break;

case'2':

FindMaxOrMin(head,'2','2');

break;

case'3':

FindMaxOrMin(head,'3','2');

break;

case'6':

FindMaxOrMin(head,'6','2');

break;

case'5':

FindMaxOrMin(head,'5','2');

break;

default:

FindMaxOrMin(head,'4','2');

break;

}

}

}

void ZengJia(string str, student*&head)

{

student*pNew=new student;

cout<<"欢迎使用增加功能"<<endl<<endl;

cout<<"请输入新学生的名字:"<<endl;

cin>>pNew->name;

cout<<"请输入新学生的座号:"<<endl;

cin>>pNew->num;

cout<<"请输入他的语文分数:"<<endl;

cin>>pNew->chinaNum;

cout<<"请输入他的数学分数"<<endl;

cin>>pNew->mathNum;

cout<<"请输入他的英语分数"<<endl;

cin>>pNew->englishNum;

cout<<"插入记录的(1->最前面 2->最后面)"<<endl;

cin>>str;

while(str[0]!='1'&& str[0]!='2')

{

cout<<"你输入错误,请重新输入."<<endl;

cout<<"插入记录的(1->最前面 2->最后面)"<<endl;

cin>>str;

}

if(str[0]=='1')

{

InsertFront(head,pNew);

}

else if(str[0]=='2')

{

InsertRear(head,pNew);

}

cout<<"新学生增加成功."<<endl;

}

void ShanChu(string str, student*&head)

{

char delStr[30];

cout<<"欢迎使用删除功能"<<endl<<endl;

cout<<"1->查询删除 2->全部删除"<<endl;

cin>>str;

while(str[0]!='1'&& str[0]!='2')

{

cout<<"输入错误,请重新输入."<<endl;

cin>>str;

}

if(str[0]=='1')

{

cout<<"请输入要删除的关键字"<<endl;

cin>>delStr;

cout<<"1->删除第一条找到的记录 2->删除所有找到的记录"<<endl;

cin>>str;

while(str[0]!='1'&&str[0]!='2')

{

cout<<"你输入错误,请重新输入."<<endl;

cin>>str;

}

cout<<"你真的要删除吗? 1->删除 2->取消"<<endl;

string s;

cin>>s;

if(str[0]=='1')

{

if(str[0]=='1')

{

Delete(head,delStr,1);

}

else

{

Delete(head,delStr,2);

}

}

else

{

cout<<"你已经取消删除了."<<endl;

}

}

else

{

cout<<"你真的要删除全部数据吗?这样会使你的数据全部丢失哦."<<endl;

cout<<"1->全部删除 2->取消删除"<<endl;

cin>>str;

if(str[0]=='1')

{

DeleteAll(head);

}

else

{

cout<<"你已经取消删除了."<<endl;

}

}

}

void PaiMing(string str, student* head)

{

string s;

cout<<"欢迎使用排名功能"<<endl<<endl;

cout<<"排名选择: 1->升序 2->降序"<<endl;

cin>>s;

cout<<"请输入要按什么排名?"<<endl;

cout<<"1->语文成绩 2->数学成绩 3->英语成绩"

<<"4->总分 5->平均分 6->座号"<<endl;

cin>>str;

while(str[0]!='1'&& str[0]!='2'&&

str[0]!='3'&& str[0]!='4'&&

str[0]!='5'&& str[0]!='6')

{

cout<<"你输入错误,请重新输入."<<endl;

cin>>str;

}

cout<<"姓名:"<<setw(8)<<"座号:"<<setw(10)

<<"语文分数:"<<setw(10)<<"数学分数:"

<<setw(10)<<"英语分数:"<<setw(8)<<"总分数:"

<<setw(8)<<"平均分:"<<setw(6)<<"名次:"<<endl<<endl;

if(s[0]=='2')

{

switch(str[0])

{

case'1':

Sort(head,'1','1');

break;

case'2':

Sort(head,'2','1');

break;

case'3':

Sort(head,'3','1');

break;

case'4':

Sort(head,'4','1');

break;

case'5':

Sort(head,'5','1');

break;

case'6':

Sort(head,'6','1');

break;

}

}

else

{

switch(str[0])

{

case'1':

Sort(head,'1','2');

break;

case'2':

Sort(head,'2','2');

break;

case'3':

Sort(head,'3','2');

break;

case'4':

Sort(head,'4','2');

break;

case'5':

Sort(head,'5','2');

break;

case'6':

Sort(head,'6','2');

break;

}

}

ShowList(head);

return;

}

void XianShi(string str, student*head)

{

Sort(head,'4','1');

string s;

cout<<"欢迎使用显示功能"<<endl;

cout<<"1->显示全部记录 2->显示记录数目"<<endl;

cin>>s;

if(s[0]=='2')

{

cout<<"记录的数目是:"<<GetLength(head)<<endl;

}

else

{

ShowList(head);

}

}

void XuiGai(string str, student*&head)

{

string s;

student*std;

cout<<"欢迎使用修改功能"<<endl;

cout<<"请输入你要按什么查询"<<endl;

cout<<"1->姓名 2->座号 3->语文成绩 4->数学成绩"

<<"5->英语成绩"<<endl;

cin>>str;

while(str[0]!='1'&& str[0]!='2'&&

str[0]!='3'&& str[0]!='4'&&

str[0]!='5')

{

cout<<"你输入错误,请重新输入."<<endl;

cin>>str;

}

char findStr[30];

cout<<"请输入要查找的关键字或关键数:"<<endl;

cin>>findStr;

switch(str[0])

{

case'1':

std=Find(head,findStr,'1');

Reword(std);

break;

case'2':

std=Find(head,findStr,'2');

Reword(std);

break;

case'3':

std=Find(head,findStr,'3');

Reword(std);

break;

case'4':

std=Find(head,findStr,'4');

Reword(std);

break;

case'5':

std=Find(head,findStr,'5');

Reword(std);

break;

}

Write(head);

if(std!=NULL)

{

cout<<"修改成功."<<endl;

}

}

int Run()

{

bool isLoad=false;

student* head=NULL;

student*pNew=new student;

head=Read();

SetTitle(false);

if(head!=NULL)

{ Sort(head,'5','1');

Count(head);

}

string str;

SetTitle(false);

cout<<"欢迎使用学生管理系统"<<endl<<endl;

cout<<" 1->用户登陆 2->退出程序"<<endl;

cin>>str;

if(str[0]=='2')

{

AboutMe();

return 0;

}

else

{

isLoad=Enter('1');

system("cls");

if(isLoad==true)

{

SetTitle(true);

cout<<"恭喜,您输入的密码正确.可以对本系统的进行任何操作."<<endl;

}

else

{

cout<<" Sorry,您输入的密码错误.你不能修改本系统的任何内容."<<endl;

}

}

begin:

cout<<endl<<endl;

cout<<"欢迎使用学生管理系统"<<endl<<endl;

cout<<" 1->增加功能 2-查询功能"<<endl;

cout<<" 3->删除功能 4-排名功能"<<endl;

cout<<" 5->显示功能 6-修改功能"<<endl;

cout<<" 7->用户设置 8-退出程序"<<endl;

cout<<"请输入您的选择:"<<endl;

cin>>str;

while(str[0]!='8')

{

if(isLoad==true&& head!=NULL)

{

cout<<endl<<endl;

if(str[0]=='1')

{

ZengJia(str, head);

Sort(head,'4','1');

Write(head);

}

else if(str[0]=='2')

{

ChaXun(str,head);

}

else if(str[0]=='3')

{

ShanChu(str,head);

Sort(head,'4','1');

Write(head);

}

else if(str[0]=='4')

{

PaiMing(str,head);

}

else if(str[0]=='5')

{

XianShi(str,head);

}

else if(str[0]=='6')

{

XuiGai(str,head);

Write(head);

}

else if(str[0]=='7')

{

cout<<"欢迎使用用户修改功能"<<endl;

isLoad=Enter('2');

}

else if(str[0]=='8')

{

AboutMe();

return 0;

}

else

{

cout<<"你输入错误,请重新输入."<<endl;

goto begin;

}

}

else if(isLoad==false&& head!=NULL)

{

if(str[0]=='2')

{

ChaXun(str,head);

}

else if(str[0]=='4')

{

PaiMing(str,head);

}

else if(str[0]=='5')

{

XianShi(str,head);

}

else

{

cout<<"你不是管理员,不能进行此项功能."<<endl;

cout<<"你只能进行查询功能显示功能排名功能"<<endl;

}

}

else if( head==NULL&& isLoad==true)

{

cout<<"系统检查到你没有任何记录,不能进行任何操作,只能增加记录."<<endl;

ZengJia(str, head);

Write(head);

head=Read();

}

else if( head==NULL&& isLoad==false)

{

cout<<"因为你没有登陆,系统又检查到你没有任何记录,你不能进行任何操作."<<endl;

}

cout<<endl<<endl;

cout<<"按任何键继续进行操作."<<endl;

getchar();

getchar();

system("cls");

goto begin;

}

AboutMe();

return 0;

}

void SetTitle(bool isLoad)

{

HWND hwnd=GetForegroundWindow();

if(isLoad==false)

{

SetWindowText(hwnd,"学生管理系统(没有登陆)");

}

else

{

SetWindowText(hwnd,"学生管理系统(已经登陆)");

}

system("color a");

}

void AboutMe()

{

char*pStr="┃\n"

"┃\n"

"┏━━━━┻━━━━┓\n"

"┃关于作者┃\n"

"┏━━━━┻━━━━━━━━━┻━━━━┓\n"

"┃┃\n"

"┃ Aauthor:**********┃\n"

"┃ QQ:*********┃\n"

"┃ E-mail:********@**.com┃\n"

"┃┃\n"

"┗━━━━━━━━━━━━━━━━━━━┛\n";

system("cls");

srand(time(0));

for(int i=0; i<strlen(pStr); i++)

{

if(pStr[i]!='')

{

Sleep(20);

}

cout<<pStr[i];

}

cout<<"Good-bye."<<endl;

cout<<endl<<endl<<endl<<endl;

}

int main()

{

Run();

return 0;

}

学生管理系统php源码谁有

php学生管理系统源码,供大家参考,具体内容如下

功能:

1.添加/删除/修改

2.数据存储.

界面分布:

index.php

--->主界面

add.php--->stu添加

action---> sql中add/del/update

(处理html表单-->mysql的数据存储&&页面跳转)

edit.php--->stu修改

menu.php

-->首页

1. index.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>学生信息管理</title>

<script>

function doDel(id){

if(confirm('确认删除?')){

window.location='action.php?action=del&id='+id;

}

}

</script>

</head>

<body>

<center>

<?php

include("menu.php");

?>

<h3>浏览学生信息</h3>

<table width="500" border="1">

<tr>

<th>ID</th>

<th>姓名</th>

<th>性别</th>

<th>年龄</th>

<th>班级</th>

<th>操作</th>

</tr>

<?php

// 1.链接数据库

try{

$pdo= new PDO("uri:mysqlPdo.ini","root","1");

}catch(PDOException$e){

die('connection failed'.$e->getMessage());

}

//2.执行sql

$sql_select="select* from stu";

//3.data解析

foreach($pdo->query($sql_select) as$row){

echo"<tr>";

echo"<th>{$row['id']}</th>";

echo"<th>{$row['name']}</th>";

echo"<th>{$row['sex']}</th>";

echo"<th>{$row['age']}</th>";

echo"<th>{$row['classid']}</th>";

echo"<td>

<a href='edit.php?id={$row['id']}'>修改</a>

<a href='javascript:void(0);' onclick='doDel({$row['id']})'>删除</a>

</td>";

echo"</tr>";

}

?>

</table>

</center>

</body>

</html>

2. add.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>学生管理系统</title>

</head>

<body>

<center>

<?php include('menu.php');?>

<h3>增加学生信息</h3>

<form action="action.php?action=add" method="post">

<table>

<tr>

<td>姓名</td>

<td><input type="text" name="name"></td>

</tr>

<tr>

<td>年龄</td>

<td><input type="text" name="age"></td>

</tr>

<tr>

<td>性别</td>

<td><input type="radio" name="sex" value="男">男</td>

<td><input type="radio" name="sex" value="女">女</td>

</tr>

<tr>

<td>班级</td>

<td><input type="text" name="classid"></td>

</tr>

<tr>

<!--<td></td>-->

<td><a rel="external nofollow" rel="external nofollow" href="index.php">返回</td>

<td><input type="submit" value="添加"></td>

<td><input type="reset" value="重置"></td>

</tr>

</table>

</form>

</center>

</body>

</html>

3. action.php

<?php

/**

* Created by PhpStorm.

* User: hyh

* Date: 16-7-7

* Time:下午9:37

*/

//1.链接数据库

try{

$pdo= new PDO("uri:mysqlPdo.ini","root","1");

}catch(PDOException$e){

// echo'Connection failed:'.$e->getMessage();

die('connection failed'.$e->getMessage());

}

//2.action的值做对操作

switch($_GET['action']){

case'add'://add

$name=$_POST['name'];

$sex=$_POST['sex'];

$age=$_POST['age'];

$classid=$_POST['classid'];

$sql="insert into stu(name, sex, age, classid) values('{$name}','{$sex}','{$age}','{$classid}')";

$rw=$pdo->exec($sql);

if($rw> 0){

echo"<script>alter('添加成功');</script>";

}else{

echo"<script>alter('添加失败');</script>";

}

header('Location: index.php');

break;

case'del'://get

$id=$_GET['id'];

$sql="delete from stu where id={$id}";

$rw=$pdo->exec($sql);

if($rw> 0){

echo"<script>alter('删除成功');</script>";

}else{

echo"<script>alter('删除失败');</script>";

}

header('Location: index.php');

break;

case'edit'://post

$id=$_POST['id'];

$name=$_POST['name'];

$age=$_POST['age'];

$classid=$_POST['classid'];

$sex=$_POST['sex'];

// echo$id,$age,$age,$name;

$sql="update stu set name='{$name}', age={$age},sex='{$sex}',classid={$classid} where id={$id};";

//$sql="update myapp.stu set name='jike',sex='女', age=24,classid=44 where id=17";

print$sql;

$rw=$pdo->exec($sql);

if($rw> 0){

echo"<script>alter('更新成功');</script>";

}else{

echo"<script>alter('更新失败');</script>";

}

header('Location: index.php');

break;

default:

header('Location: index.php');

break;

}

4.edit.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>学生管理系统</title>

</head>

<body>

<center>

<?php include('menu.php');

//1.链接数据库

try{

$pdo= new PDO("uri:mysqlPdo.ini","root","1");

}catch(PDOException$e){

die('connection failed'.$e->getMessage());

}

//2.执行sql

$sql_select="select* from stu where id={$_GET['id']}";

$stmt=$pdo->query($sql_select);

if($stmt->rowCount()>0){

$stu=$stmt->fetch(PDO::FETCH_ASSOC);//解析数据

}else{

die("no have this id:{$_GET['id']}");

}

?>

<h3>修改学生信息</h3>

<form action="action.php?action=edit" method="post">

<input type="hidden" name="id" value="<?php echo$stu['id'];?>">

<table>

<tr>

<td>姓名</td>

<td><input type="text" name="name" value="<?php echo$stu['name'];?>"></td>

</tr>

<tr>

<td>年龄</td>

<td><input type="text" name="age" value="<?php echo$stu['age'];?>"></td>

</tr>

<tr>

<td>性别</td>

<td>

<input type="radio" name="sex" value="男"<?php echo($stu['sex']=="男")?"checked":"";?>>男

</td>

<td>

<input type="radio" name="sex" value="女"<?php echo($stu['sex']=="女")?"checked":"";?>>女

</td>

</tr>

<tr>

<td>班级</td>

<td><input type="text" name="classid" value="<?php echo$stu['classid']?>"></td>

</tr>

<tr>

<td></td>

<td><input type="submit" value="更新"></td>

<td><input type="reset" value="重置"></td>

</tr>

</table>

</form>

</center>

<?php

?>

</body>

</html>

5. menu.php

<!DOCTYPE html>

<html lang="en">

<body>

<h2>学生管理系统</h2>

<a rel="external nofollow" rel="external nofollow" href="index.php">浏览学生</a>

<a rel="external nofollow" href="add.php">添加学生</a>

<hr>

</body>

</html>

学生信息管理系统最简单源代码。

方法一:

1、创建一个c语言项目。然后右键头文件,创建一个Stu的头文件。

2、然后编写头文件的代码。再将数据结构的增删改查和结构体写入头文件。

3、然后在源文件中创建main源文件和Stu源文件。再main文件中写入intmian()代码。

4、然后在mian主函数中,写入while语句无限循环。再写入Init函数。

5、在Stu源文件的Init函数用printf语句,将学生管理系统输出。再创建链表的头节点head。

6、然后用switch函数对操作进行判断。再执行数据结构的增删改查功能。这样一个学生管理系统的基本框架就完成了。

方法二:

1、新建一个学生实体类,用于存放学生的各项信息。

2、新建一个链表节点类,每个节点存放一个学生信息及下一个节点的引用。

3、添加一个主操作类,并添加本系统的菜单方法。

4、定义链表的头节点,当前最后一个节点,以及主控制逻辑信息。

5、使用io流逐行读取存有学生信息的文本文件,对每行字符串,采用\t分割后得到一个字符串数组,数据各项即为一个学生的具体信息。然后新建一个节点加入到链表。

6、运行结果:

END,本文到此结束,如果可以帮助到大家,还望关注本站哦!

洛阳网站建设(洛阳网站建设哪家好洛阳专业做网站公司有哪些)站长素材?站长素材商用使用范围