導航:首頁 > 源碼編譯 > 源碼學生管理系統

源碼學生管理系統

發布時間:2023-03-17 15:24:37

A. 學生管理系統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 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 href="index.php"> 瀏覽學生</a>
<a href="add.php"> 添加學生</a>
<hr>
</body>
</html>

B. C語言實現 學生成績管理系統(超詳細) 內附源碼

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

#include<conio.h>

#define N 50//定義的學生數組的個數

#define M 1//定義的管理員數組的個數

int k;//錄入學生的個數

char read_door[20];//讀取文件的"門"

void Add_data(int flag);//增加數據

void Count_score(int flag);//求平均成績和總成績

void Delete_data(int flag);//根據學號刪除對應學生的成績

int Landing(int key);//登錄程序

void Load_data();//載入數據

void Updata_stu(int flag);

void Read_bigdoor(char *b);

void Rank_score(int way, int flag);//按照需求對對應的成績排序

void Read_data(char read_door);//讀取數據

void Read_door();//讀取"門"值

void Read_main_flag(int *a);

void Read_k();

void Save_bigdoor(char *b);

void Save_data(int flag);//保存數據

void Save_door();//保存"門"值

void Save_main_flag(int *a);

void Save_k(int k);

void Screen_rank();

void Screen_search();

void Screen_stu();

void Screen_teacher();

void Screen_stu_teach();

void Screen_onlyteach();

void Search_data(int way, int flag);//按學號或姓名查找查找

static struct STUDENT//學生的信息

{

char num[10];

char name[10];

float score[3];

float sum;

float aver;

int rank[4];

}stu[N];

static struct TEACHER//教師的登錄賬號和密碼

{

char num[10];

char code[10];

}teach[M] = { "18061124","991228" };

int main()

{

char bigdoor ='n';//教師可通過bigdoor控制學生的許可權

char *c=&bigdoor;

int order1, order2, order3;//order為用戶登錄的指令

int door1, door2, door3;

printf ("請輸入管理員登錄指令:\n");

gets(read_door);

if (strcmp(read_door,"Lu Chen")==0)

{

printf("歡迎使用,您目前是擁有最高許可權的管理員,請輸入您的賬號和密碼:\n\n");

printf("\n\n\n");

Screen_onlyteach();

door1 = Landing(1);

if (door1 == 2)

{

printf("\n賬號或密碼不正確");

return 0;

}

}

else

{

Screen_stu_teach();

printf("請輸入序號即選擇登錄選項:");

scanf("%d", &order1);

printf("\n\n");

door1 = Landing(order1);//door1確定用戶的許可權

switch (door1)//提示用戶輸入出錯

{

case 1:

case 3: break;

case 2:printf("\n輸入的賬號或密碼有誤"); return 0;

case 4:printf("\n輸入的號碼有誤"); return 0;

}

}

if (door1 == 1)//老師界面

{

int flag = 0;

int *p=&flag;

char teach_read_key;

printf("\n是否讀取數據?(y/n):");

scanf("%*c%c",&teach_read_key);

if(teach_read_key=='y')

{

Read_k();

    Read_door();

Read_main_flag(p);

Read_data(read_door[20]);

}

printf("\n\n");

for (int count = 1; count > 0; count++)//利用死循環來重復使用功能

{

Screen_teacher();

printf("\n請輸入序號即選擇登錄選項:");

scanf("%d", &order2);

printf("\n\n");

if (order2 == 10)

break;

switch (order2)

{

case 1:

{

Load_data();

flag=1;

Save_main_flag(p);

Save_k(k);

}break;

case 2:Updata_stu(flag); break;

case 3:

{

Screen_search();

printf("請輸入你想查詢成績的方式:");

scanf("%d", &door2);

Search_data(door2, flag);

}break;

case 4:Add_data(flag);break;

case 5:Delete_data(flag);break;

case 6:

{

Screen_rank();

printf("請輸入成績序號來選擇排序:");

scanf("%d", &door2);

Rank_score(door2, flag);

} break;

case 7:

{

Save_data(flag);

Save_door();

Save_k(k);

} break;

case 8:

{

bigdoor ='n';

Save_bigdoor(c);

}break;

case 9:

{

bigdoor ='y';

Save_bigdoor(c);

  }break;

default:printf("您輸入的序號有誤!\n\n");

}

}

}

else//學生界面

{

Read_k();

Read_data('y');

for (int k = 1; k > 0; k++)

{

Screen_stu();

printf("請輸入下一步操作的序號:");

scanf("%d", &order3);

if (order3 == 3)

break;

switch (order3)

{

case 1:

{

Screen_search();

printf("請輸入你想查詢成績的方式");

scanf("%d", &door3);

Search_data(door3, 1);

}break;

case 2:

{

Screen_rank();

printf("請輸入成績序號來選擇排序:");

scanf("%d", &door3);

Rank_score(door3, 1);

}break;

default:printf("輸入的操作序號有誤\n\n");

}

}

}

return 0;

}

int Landing(int key)//登錄程序

{

char num[10];

char code[10];

if (key == 1)

{

printf("請輸入賬號:");

scanf("%s", num);

printf("\n請輸入密碼:");

scanf("%s", code);

for (int i = 0; i < M; i++)

if (strcmp(teach[i].num, num) == 0 && strcmp(teach[i].code, code) == 0)//判斷登陸賬號和密碼是否正確

return 1;

else

return 2;

}

else if (key == 2)

{

return 3;

}

else

{

return 4;

}

}

void Search_data(int way, int flag)//按學號或姓名查找查找

{

int Search_flag = 1;

if (flag)

{

char num[10], name[10];

int i;

if (way == 1)

{

printf("\n請輸入學號:");

scanf("%s", num);

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

{

if (strcmp(stu[i].num, num) == 0)//判斷學號存不存在

{

printf("\n姓名:%s\n學號:%s\nsubject1:%f\nsubject2:%f\nsubject3:%f\nsum:%f\naver:%f\n", stu[i].name, stu[i].num, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].sum, stu[i].aver);

Search_flag = 0;

break;

}

}

if (Search_flag)

printf("\n您輸入的學號有誤\n");

}

else if (way == 2)

{

printf("\n請輸入姓名:");

scanf("%s", name);

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

{

if (strcmp(stu[i].name, name) == 0)//判斷姓名存不存在

{

printf("\n姓名:%s\n學號:%s\nsubject1:%f\nsubject2:%f\nsubject3:%f\nsum:%f\naver:%f\n", stu[i].name, stu[i].num, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].sum, stu[i].aver);

flag = 0;

break;

}

}

if (flag)

printf("\n輸入的姓名有誤\n");

}

else

printf("\n輸入的序號有誤\n");

}

else

{

printf("\n您還沒有載入數據\n");

}

}

void Count_score(int flag)//求平均成績和總成績

{

if (flag)

{

for (int i = 0; i < k; i++)

{

stu[i].sum = stu[i].score[0] + stu[i].score[1] + stu[i].score[2];

stu[i].aver = stu[i].sum / 3;

}

}

else

{

printf("\n您還沒有載入數據\n");

}

}

void Load_data()//載入數據

{

printf("輸入錄入學生成績個數:");

scanf("%d", &k);

for (int i = 0; i < k; i++)

{

scanf("%s%s%f%f%f", stu[i].num, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2]);

Count_score(1);

}

}

void Rank_score(int way, int flag)//按照需求對對應的成績排序

{

int i, j, n, temp;

if (flag)

{

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

for (j = 0; j < k; j++)

stu[j].rank[i] = j + 1;

if (way == 1)

{

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

for (j = 0; j < k; j++)

for (n = j + 1; n < k; n++)

if (stu[j].score[i] < stu[n].score[i])

{

temp = stu[j].rank[i];

stu[j].rank[i] = stu[n].rank[i];

stu[n].rank[i] = temp;

}

printf("\n");

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

printf("姓名:%s 學號:%s subject1:%d subject2:%d subject3:%d\n", stu[i].name, stu[i].num, stu[i].rank[0], stu[i].rank[1], stu[i].rank[2]);

}

else if (way == 2)

{

for (j = 0; j < k; j++)

for (n = j + 1; n < k; n++)

if (stu[j].sum < stu[n].sum)

{

temp = stu[j].rank[3];

stu[j].rank[3] = stu[n].rank[3];

stu[n].rank[3] = temp;

}

printf("\n");

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

printf("姓名:%s 學號:%s sum: %d\n", stu[i].name, stu[i].num, stu[i].rank[3]);

}

else

{

printf("\n輸入的序號有誤\n");

}

}

else

{

printf("\n您還沒有載入數據\n");

}

}

void Delete_data(int flag)//根據學號刪除對應學生的成績

{

if (flag)

{

int i, j;

char num[10];

printf("\n請輸入您想要刪除信息的學號:");

scanf("%s", num);

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

{

if (strcmp(stu[i].num, num) == 0)

for (j = i + 1; j < k; j++)

{

stu[i] = stu[j];

Count_score(1);

}

}

k--;

Save_k(k);

}

else

{

printf("\n您還沒有載入數據\n");

}

}

void Updata_stu(int flag)//根據學號修改學生的成績

{

int Updata_flag = 1;

if (flag)

{

char num[10];

float subject1, subject2, subject3;

printf("\n請輸入您想要修改學生的學號:");

scanf("%s", num);

printf("\n請輸入您想要更改的學生三科的成績:");

scanf("%f%f%f", &subject1, &subject2, &subject3);

for (int i = 0; i < k; i++)

if (strcmp(stu[i].num, num) == 0)

{

stu[i].score[0] = subject1;

stu[i].score[1] = subject2;

stu[i].score[2] = subject3;

Updata_flag = 0;

Count_score(1);

}

if (Updata_flag)

{

printf("\n輸入學號有誤\n");

}

}

else

{

printf("\n您還沒有載入數據\n");

}

}

void Save_data(int flag)//保存數據

{

if(flag)

{

FILE *fp;

if((fp=fopen("load.txt","w"))==NULL)

{

printf("Save_data error!");

exit(0);

}

for(int i=0;i<k;i++)

{

fwrite(&stu[i],sizeof(STUDENT),1,fp);

}

fclose(fp);

printf("成功保存數據!\n\n");

read_door[20]='y';

}

else

{

printf("\n您還沒有載入數據\n");

}

}

void Read_data(char read_door)//讀取數據

{

if(read_door=='y')

{

FILE *fp;

if((fp=fopen("load.txt","r"))==NULL)

{

printf("Read_data error!");

exit(0);

}

for(int i=0;i<k;i++)

{

fread(&stu[i],sizeof(STUDENT),1,fp);

}

fclose(fp);

}

else

{

printf("\n沒有保存數據的記錄\n");

}

}

void Save_door()//保存"門"值

{

FILE *fp;

if((fp=fopen("door.txt","w"))==NULL)

{

printf("Save_door error!");

exit(0);

}

fputc(read_door[20],fp);

fclose(fp);

}

void Read_door()//讀取"門"值

{

FILE *fp;

if((fp=fopen("door.txt","r"))==NULL)

{

printf("Read_door error!");

exit(0);

}

read_door[20]=fgetc(fp);

fclose(fp);

}

void Save_main_flag(int *a)

{

FILE *fp;

if((fp=fopen("flag.txt","w"))==NULL)

{

printf("Save_main_flag error!");

exit(0);

}

fprintf(fp,"%d",*a);

fclose(fp);

}

void Read_main_flag(int *a)

{

FILE *fp;

if((fp=fopen("flag.txt","r"))==NULL)

{

printf("Read_main_flag error!");

exit(0);

}

fscanf(fp,"%d",a);

fclose(fp);

}

void Save_bigdoor(char *b)

{

FILE *fp;

if((fp=fopen("bigdoor.txt","w"))==0)

{

printf("Save_bigdoor error!");

exit(0);

}

fputc(*b,fp);

fclose(fp);

}

void Read_bigdoor(char *b)

{

FILE *fp;

if((fp=fopen("bigdoor.txt","r"))==0)

{

printf("Read_bigdoor error!");

exit(0);

}

*b=fgetc(fp);

fclose(fp);

}

void Save_k(int k)

{

FILE *fp;

if((fp=fopen("k.txt","w"))==0)

{

printf("Save_k error!");

exit(0);

}

fprintf(fp,"%d",k);

fclose(fp);

}

void Read_k()

{

FILE *fp;

if((fp=fopen("k.txt","r"))==0)

{

printf("Read_k error!");

exit(0);

}

fscanf(fp,"%d",&k);

fclose(fp);

}

void Add_data(int flag)//增加數據

{

int i, j,count=k;

char num[10], name[10];

float subject1, subject2, subject3;

if (flag)

{

printf("\n輸入您想增加的數據條數:");

scanf("%d", &i);

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

{

printf("\n輸入增加的學生學號,姓名,三門科目成績");

scanf("%s%s%f%f%f", num, name, &subject1, &subject2, &subject3);

strcpy(stu[count + j].num, num);

strcpy(stu[count+ j].name, name);

stu[count+ j].score[0] = subject1;

stu[count + j].score[1] = subject2;

stu[count+ j].score[2] = subject3;

k++;

Count_score(1);

}

Save_k(k);

}

else

{

printf("\n輸入您想增加的數據條數:");

scanf("%d", &i);

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

{

printf("\n輸入增加的學生學號,姓名,三門科目成績");

scanf("%s%s%f%f%f", num, name, &subject1, &subject2, &subject3);

strcpy(stu[j].num, num);

strcpy(stu[j].name, name);

stu[j].score[0] = subject1;

stu[j].score[1] = subject2;

stu[j].score[2] = subject3;

k++;

Count_score(1);

}

}

}

void Screen_search()//查詢界面

{

printf("*****************學生成績查詢界面*******************\n\n\n");

printf("——————————————————————————\n");

printf("|              ①  學生學號查詢                    |\n");

printf("|              ②  學生姓名查詢                    |\n");

printf("——————————————————————————\n");

}

void Screen_rank()//成績排名方式界面

{

printf("*****************學生成績排名界面*******************\n\n\n");

printf("——————————————————————————\n");

printf("|              ①    subject                      |\n");

printf("|              ②      sum                        |\n");

printf("——————————————————————————\n");

}

void Screen_teacher()

{

printf("*****************教師管理操作界面*******************\n\n\n");

printf("——————————————————————————\n");

printf("|              ①    數據載入                      |\n");

printf("|              ②    修改數據                      |\n");

printf("|              ③    查詢數據                      |\n");

printf("|              ④    添加數據                      |\n");

printf("|              ⑤    刪除數據                      |\n");

printf("|              ⑥    成績排序                      |\n");

printf("|              ⑦    保存數據                      |\n");

printf("|              ⑧    學生限制                      |\n");

printf("|              ⑨    學生開放                      |\n");

printf("|              ⑩      退出                        |\n");

printf("——————————————————————————\n");

}

void Screen_stu_teach()

{

printf("*****************學生成績管理系統*******************\n\n\n");

printf("——————————————————————————\n");

printf("|              ① 教師管理員登錄                  |\n");

printf("|              ②  學生端登錄                    |\n");

printf("——————————————————————————\n");

}

void Screen_onlyteach()

{

printf("*****************教師登陸操作界面*******************\n\n\n");

printf("——————————————————————————\n");

printf("|              ① 教師管理員登錄                  |\n");

printf("——————————————————————————\n");

}

void Screen_stu()

{

printf("*****************學生用戶操作界面*******************\n\n\n");

printf("——————————————————————————\n");

printf("|              ①  學生成績查詢                    |\n");

printf("|              ②  成績排名查詢                    |\n");

printf("|              ③      退出                        |\n");

printf("——————————————————————————\n");

}

以上內容僅是本人通過多方瀏覽網上資料,自己敲出來的。

如有問題,大家可以在評論區下方留言!!!

本人已親測,可用

C. 學生信息管理系統源代碼

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;
}

D. 誰有Java實現的學生信息管理系統源碼

可以試試看啊
以下方法實現了用戶界面登陸
import java.awt.*;
import java.awt.event.*;
public class DengLuJieMian extends Frame implements ActionListener
{
Label username=new Label("用戶名:");//使用文本創建一個用戶名標簽
TextField t1=new TextField();//創建一個文本框對象
Label password=new Label("密碼:");//創建一個密碼標簽
TextField t2=new TextField();
Button b1=new Button("登陸");//創建登陸按鈕
Button b2=new Button("取消");//創建取消按鈕
public DengLuJieMian()
{
this.setTitle("學生信息管理系統");//設置窗口標題
this.setLayout(null);//設置窗口布局管理器
username.setBounds(50,40,60,20);//設置姓名標簽的初始位置
this.add(username);// 將姓名標簽組件添加到容器
t1.setBounds(120,40,80,20);// 設置文本框的初始位置
this.add(t1);// 將文本框組件添加到容器
password.setBounds(50,100,60,20);//密碼標簽的初始位置
this.add(password);//將密碼標簽組件添加到容器
t2.setBounds(120,100,80,20);//設置密碼標簽的初始位置
this.add(t2);//將密碼標簽組件添加到容器
b1.setBounds(50,150,60,20);//設置登陸按鈕的初始位置
this.add(b1);//將登陸按鈕組件添加到容器
b2.setBounds(120,150,60,20);//設置取消按鈕的初始位置
this.add(b2);// 將取消按鈕組件添加到容器
b1.addActionListener(this);//給登陸按鈕添加監聽器
b2.addActionListener(this);// 給取消按鈕添加監聽器

this.setVisible(true);//設置窗口的可見性
this.setSize(300,200);//設置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});//通過內部類重寫關閉窗體的方法
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)//處理登陸事件
{
String name=t1.getText();
String pass=t2.getText();
if(name!=null&&pass.equals("000123"))//判斷語句
{
new StudentJieMian();
}
}
}
public static void main(String args[])//主函數
{
new DengLuJieMian();
}
}
以下方法實現了學生界面設計
import java.awt.*;
import java.awt.event.*;
class StudentJieMian extends Frame implements ActionListener
{
MenuBar m=new MenuBar();//創建菜單欄
Menu m1=new Menu("信息");//創建菜單「信息」
MenuItem m11=new MenuItem("插入");//創建「插入」的菜單項
MenuItem m12=new MenuItem("查詢");
Menu m2=new Menu("成績");//創建菜單「成績」
MenuItem m21=new MenuItem("查詢");
public StudentJieMian()
{
this.setTitle("學生界面");//設置窗口標題
this.setLayout(new CardLayout());//設置窗口布局管理器
this.setMenuBar(m);//將菜單欄組件添加到容器
m.add(m1);//將信息菜單放入菜單欄
m.add(m2);
m1.add(m11);//將「插入」菜單項添加到「信息」菜單
m1.add(m12); //將「查詢」菜單項添加到「信息」菜單
m2.add(m21); //將「查詢」菜單項添加到「成績」菜單
m11.addActionListener(this); //給「插入」菜單項添加監聽器
m12.addActionListener(this); //給「查詢」菜單項添加監聽器
m21.addActionListener(this); //給「查詢」菜單項添加監聽器
this.setVisible(true); //設置窗口的可見性
this.setSize(300,200); //設置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);//關閉窗口
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==m11) //處理「添加信息」事件
{
new AddStudent();
}
if(e.getSource()==m12) //處理「查詢信息」事件
{
new SelectStudent();
}
if(e.getSource()==m21) //處理「查詢成績」事件
{
new ChengJiStudent();
}
}
public static void main(String args[])

E. 學生信息管理系統最簡單源代碼。

方法一:

1、創建一個c語言項目。然後右鍵頭文件,創建一個Stu的頭文件。

F. 學生信息管理系統C++源代碼

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<malloc.h>
#define INIT_SIZE 10
#define INCRE_SIZE 10
#define SUBJECT_NUM 3
#define LEN 3

void show_Start();

void show_Table();

void addRecord();

void Info_delete();
void deleteRecord();
void delete_Num(int);
void delete_Name(char tarName[]);

void Info_modify();
void modifyRecord();
void modify_Num(int);
void modify_Name(char[]);

void Info_query();
void queryRecord();
void query_Num(int);
void query_Name(char[]);

void display();

void quit();

void menu_CMD();

char *subject[SUBJECT_NUM] = {"高代","數分","C語言"};

struct STUDENT
{
int num;
char name[20];
char sex;
float score[SUBJECT_NUM];
};

//struct STUDENT stu[LEN + 1];

//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);

int static stuNum = 0;
//先暫時定義三個學生吧...

STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);;

int main()
{
//record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);
//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);

/*
record[1].num = 1001;
strcpy(record[1].name,"Jason");
record[1].sex = 'M';
record[1].score[0] = 85.0;
record[1].score[1] = 90.0;
record[1].score[2] = 95.0;

record[2].num = 1002;
strcpy(record[2].name,"Jerry");
record[2].sex = 'M';
record[2].score[0] = 85.0;
record[2].score[1] = 90.0;
record[2].score[2] = 95.0;

record[3].num = 1003;
strcpy(record[3].name,"Jessie");
record[3].sex = 'F';
record[3].score[0] = 85.0;
record[3].score[1] = 90.0;
record[3].score[2] = 95.0;
*/

/*
Info_modify();
int key;
cout<<"請輸入您的選擇 : ";
cin>>key;

if(key == 1)
{
int targetNum;
cout<<"請輸入您欲修改的學生的學號 : ";
cin>>targetNum;

modify_Num(targetNum);
cout<<endl;

display();
}

if(key == 2)
{
char targetName[20];
cout<<"請輸入您欲修改學生的姓名 : ";
cin>>targetName;

modify_Name(targetName);
cout<<endl;

display();
}

if(key == 3)
{
exit(0);
}
*/

show_Start();

menu_CMD();

return 0;

}

//修改完後還應該顯示
void show_Start()
{
//cout<<endl;
cout<<" **************************************** "<<endl;
cout<<" 這是一個 "<<endl;
cout<<" 學生成績管理系統 "<<endl;
cout<<" 可以對學生成績進行管理 "<<endl;
cout<<" 歡迎大家使用 "<<endl;
cout<<" Made by Jason "<<endl;
cout<<" **************************************** "<<endl;
}

// 顯示表頭信息,即是 : 學號,姓名,性別,高代,數分,C語言.
void show_Table()
{
cout<<"學號"<<"\t"<<"姓名"<<"\t"<<"性別";
cout<<"\t"<<subject[0]<<"\t"<<subject[1]<<"\t"<<subject[2];
cout<<endl;
}

void menu_CMD()
{
int key;
while(1)
{
cout<<"1. 增加學生信息"<<endl;
cout<<"2. 刪除學生信息"<<endl;
cout<<"3. 修改學生信息"<<endl;
cout<<"4. 查詢學生信息"<<endl;
cout<<"5. 顯示學生信息"<<endl;
cout<<"6. 退出"<<endl;
cout<<"請輸入您的選擇 : ";
cin>>key;
while(1)
{
if((key < 1)||(key > 6))
{
int key;
cout<<"您的輸入有誤,請重新輸入!"<<endl;
cout<<"請選(1 - 5) : ";
cin>>key;
}
else
{
break;
}
}
switch(key)
{
case 1:
addRecord();
break;
case 2:
deleteRecord();
break;
case 3:
modifyRecord();
break;
case 4:
queryRecord();
break;
case 5:
display();
break;
case 6:
quit();
break;
}

}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

//增加學生信息
void addRecord()
{

if(stuNum == 0)
{
cout<<"原來沒有記錄,現在建立新表!"<<endl;
stuNum++;
}
else
{
cout<<"現在在當前表的末尾添加新的信息!"<<endl;
stuNum++;
}

//如果數組空間不夠,重新申請空間
if(stuNum > INIT_SIZE)
{
cout<<"內存空間不夠,現在重新申請新的內存空間!"<<endl;
record = (STUDENT*)realloc(record,(INIT_SIZE + INCRE_SIZE)*sizeof(STUDENT));
cout<<"空間申請完成!"<<endl;
}

cout<<"您現在要添加一組新的信息,您確定嗎?"<<endl;
cout<<"請輸入您的選擇(Y/N) : ";
char choi;
cin>>choi;
if((choi == 'Y')||(choi == 'y'))
{
cout<<"請輸入學號 : ";
cin>>record[stuNum].num;
cout<<"請輸入姓名 : ";
cin>>record[stuNum].name;
cout<<"請輸入性別(M為男,F為女) : ";
cin>>record[stuNum].sex;

int i;
for(i = 0;i < SUBJECT_NUM;i++)
{
cout<<"請輸入"<<subject[i]<<"的成績 : ";
cin>>record[stuNum].score[i];
}
}

if((choi == 'N')||(choi == 'n'))
{
cout<<"退出添加新學生信息!"<<endl;
cout<<endl;
}

cout<<"現在已經有"<<stuNum<<"條學生的信息了!"<<endl;
cout<<endl;
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//刪除信息 晚上完成...

//顯示deleteRecord的表頭信息
void Info_delete()
{
cout<<"請輸入刪除方式 : "<<endl;
cout<<"1. 按學號刪除"<<endl;
cout<<"2. 按姓名刪除"<<endl;
cout<<"3. 退出刪除"<<endl;
}

//刪除學生的信息,包含兩個子函數
void deleteRecord()
{
int key;
cout<<endl;
Info_delete();
cout<<"請輸入您的選擇 : ";
cin>>key;

if(key == 1)
{
int targetNum;
cout<<"請輸入您欲刪除學生的學號 : ";
cin>>targetNum;

//按學號刪除
delete_Num(targetNum);
cout<<endl;
}

if(key == 2)
{
char targetName[20];
cout<<"請輸入您欲刪除學生的姓名 : ";
cin>>targetName;

//按姓名刪除
delete_Name(targetName);
cout<<endl;
}

if(key == 3)
{
while(1)
{
menu_CMD();

}
}
}

//按學號刪除學生信息
//只用完成刪除操作,而不必輸出. 輸出的操作可以在主菜單中進行

void delete_Num(int tarNum)
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(record[i].num == tarNum)
{
//刪除還要分兩種情況討論
//1. 欲刪除的學生信息是最後一位
//2. 欲刪除的學生信息不是最後一位

//第一種情況,欲刪除的學生是最後一位
if(i = stuNum)
{
cout<<"您所要刪除的學生信息是 : "<<endl;
show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"
<<record[i].score[0]<<record[i].score[1]<<"\t"<<record[i].score[2];
cout<<endl;

cout<<endl<<"刪除後學生信息表為 : "<<endl;
show_Table();
for(int i = 1;i <= stuNum - 1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
//顯示信息應該放在後面
/*
stuNum--;
cout<<"現在還剩下"<<stuNum<<"條學生的信息";
cout<<endl;
*/
}

//2.第二種情況,欲刪除的學生不是最後一位
if(i != stuNum)
{

cout<<"您所要刪除的學生信信息是 : "<<endl;
show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"
<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];

for(int j = i+1;j <= stuNum;j++)
{
record[j-1] = record[j];
}

//接著完成輸出

cout<<endl;
cout<<"刪除後學生信息表為 : "<<endl;
show_Table();
for(int i = 1;i <= stuNum-1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
/*
stuNum--;
cout<<"現在還剩下"<<stuNum<<"條學生的信息";
cout<<endl;
*/
}

stuNum--;
cout<<"現在還是剩下"<<stuNum<<"條學生的信息";
cout<<endl;
}
}
}

/*

//方法同上
void delete_Name(char tarName[])
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(strcmp(record[i].name,tarName) == 0)
{
//刪除還要分兩種情況討論
//1. 欲刪除的學生信息是最後一位
//2. 欲刪除的學生信息不是最後一位

//第一種情況 : 欲刪除學生是最後一位
if(i = stuNum)
{
cout<<"您所要刪除的學生信息是 : "<<endl;
show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"
<<record[i].score[0]<<record[i].score[1]<<"\t"<<record[i].score[2];
cout<<endl;

cout<<endl<<"刪除後學生信息表為 : "<<endl;
show_Table();
for(int i = 1;i <= stuNum - 1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
}

//第二種情況 : 欲刪除學生不是最後一位
if(i != stuNum)
{

cout<<"您所要刪除的學生信信息是 : "<<endl;
show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"
<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];

//整體往前 前移一位
for(int j = i+1;j <= stuNum;j++)
{
record[j-1] = record[j];
}
cout<<endl;

//接著完成輸出
cout<<"刪除後學生信息表為 : "<<endl;
show_Table();
for(int i = 1;i <= stuNum-1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}

cout<<endl;
}
}

}

}

*/

void delete_Name(char tarName[])
{
int i;
for(i = 1;i <= stuNum;i++)
{

//刪除還要分兩種情況討論
//1. 欲刪除的學生信息是最後一位
//2. 欲刪除的學生信息不是最後一位

//當欲刪除的學生是最後一位,直接輸出前面LEN-1位學生的信息

if(strcmp(record[i].name,tarName) == 0)
{
if(i == stuNum)
{
cout<<"您所要刪除的學生信息是 : "<<endl;
show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"
<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];

cout<<endl;

cout<<"刪除後學生信息表為 : "<<endl;
show_Table();
for(int i = 1;i <= stuNum-1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
/*
stuNum--;
cout<<"現在還剩下"<<stuNum<<"條學生的信息";
cout<<endl;
*/
}

//當欲刪的學生不是最後一位,整體往前前移一位
if(i != stuNum)
{
cout<<"您所要刪除的學生信息是 : "<<endl;

show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t";
cout<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];
cout<<endl;

//整體往前前移一位
for(int j = i+1;j <= stuNum;j++)
{
record[j-1] = record[j];
}

//然後輸出
cout<<endl;
cout<<"刪除後學生信息表為 : "<<endl;

show_Table();
for(int i = 1;i <= stuNum-1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
/*
stuNum--;
cout<<"現在還剩下"<<stuNum<<"條學生的信息";
cout<<endl;
*/
}

stuNum--;
cout<<"現在還剩下"<<stuNum<<"條學生的信息";
cout<<endl;
}
}
}

/*****************************************************************************
******************************************************************************/

//顯示modifyRecord的表頭信息
void Info_modify()
{
cout<<"請輸入修改方式 : "<<endl;
cout<<"1. 按學號修改"<<endl;
cout<<"2. 按姓名修改"<<endl;
cout<<"3. 退出修改"<<endl;
}

//查詢學生的成績,當然裡麵包括兩個子函數
void modifyRecord()
{
int key;
cout<<endl;
Info_modify();
cout<<"請輸入您的選擇 : ";
cin>>key;

//按學號修改
if(key == 1)
{
int targetNum;
cout<<"請輸入您欲修改的學生的學號 : ";
cin>>targetNum;

modify_Num(targetNum);
cout<<endl;

//display();
}

//按姓名修改
if(key == 2)
{
char targetName[20];
cout<<"請輸入您欲修改學生的姓名 : ";
cin>>targetName;

modify_Name(targetName);
cout<<endl;

//display();
}

//退出修改
if(key == 3)
{
while(1)
{
menu_CMD();
}
}
}

//按學號修改
void modify_Num(int tarNum)
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(record[i].num == tarNum)
{
cout<<endl<<"請修改該學生的信息"<<endl;
cout<<"請輸入該學生的學號 : ";
cin>>record[i].num;
cout<<"請輸入該學生的姓名 : ";
cin>>record[i].name;
cout<<"請輸入該學生的性別 : ";
cin>>record[i].sex;
cout<<"請輸入"<<subject[0]<<"的成績 : ";
cin>>record[i].score[0];
cout<<"請輸入"<<subject[1]<<"的成績 : ";
cin>>record[i].score[1];
cout<<"請輸入"<<subject[2]<<"的成績 : ";
cin>>record[i].score[2];
}
}
}

//按姓名修改
void modify_Name(char tarName[])
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(strcmp(record[i].name,tarName) == 0)
{
cout<<endl<<"請修改該學生的信息 : "<<endl;
cout<<"請輸入該學生的學號 : ";
cin>>record[i].num;
cout<<"請輸入該學生的姓名 : ";
cin>>record[i].name;
cout<<"請輸入該學生的性別 : ";
cin>>record[i].sex;
cout<<"請輸入"<<subject[0]<<"的成績 : ";
cin>>record[i].score[0];
cout<<"請輸入"<<subject[1]<<"的成績 : ";
cin>>record[i].score[1];
cout<<"請輸入"<<subject[2]<<"的成績 : ";
cin>>record[i].score[2];
}
}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

//顯示queryRecord的表頭信息
void Info_query()
{
cout<<"請輸入查詢方式 : "<<endl;
cout<<"1. 按學號查詢"<<endl;
cout<<"2. 按姓名查詢"<<endl;
cout<<"3. 退出查詢"<<endl;
}

//查詢學生信息queryRecord
void queryRecord()
{
int key;
cout<<endl;
Info_query();
cout<<"請輸入您的選擇 : ";
cin>>key;

if(key == 1)
{
int targetNum;
cout<<"請輸入您欲查詢學生的學號 : ";
cin>>targetNum;

query_Num(targetNum);
cout<<endl;
}

if(key == 2)
{
char targetName[20];
cout<<"請輸入您欲查詢學生的學號 : ";
cin>>targetName;

query_Name(targetName);
cout<<endl;
}

//退出查詢,退回到主菜單吧...
if(key == 3)
{
while(1)
{
menu_CMD();
}
}
}

//按學號查詢
void query_Num(int tarNum)
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(record[i].num == tarNum)
{
//如果表中有該學生信息的話,僅用輸出該學生的信息即可.
//輸出該學生的信息
cout<<"該學生的信息如下 : "<<endl;

//顯示表頭信息
show_Table();

//顯示該學生具體的信息
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
cout<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];
cout<<endl;
}
}
}

//按姓名查詢
void query_Name(char tarName[])
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(strcmp(record[i].name,tarName) == 0)
{
cout<<"該學生的信息如下 : "<<endl;

show_Table();

cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
cout<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];
cout<<endl;
}
}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

//先顯示所有學生的信息吧
//顯示record里所有學生的成績
void display()
{
show_Table();
int i,j;
for(i = 1;i <= stuNum;i++)
{
//cout<<"學號"<<"\t"<<"姓名"<<"\t"<<"性別";
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
cout<<endl;
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//退出
void quit()
{
char choi;
cout<<"您確定要退出嗎?"<<endl;
cout<<"請輸入您的選擇(Y/N) : ";
cin>>choi;
if((choi == 'Y')||(choi == 'y'))
{
cout<<"現在退出學生信息管理系統"<<endl;
exit(0);
}
//如果不是退出,則接著退回到主界面
else
{
cout<<endl;
menu_CMD();
}

}

這個是原創的... 在C-Free 4.0里跑過,可以正常運行
你可以試著跑一下,如果有什麼問題可以和我聯系

閱讀全文

與源碼學生管理系統相關的資料

熱點內容
單片機啟動文件 瀏覽:804
橙app如何開啟聊天 瀏覽:899
訪問伺服器公網地址 瀏覽:666
pdf列印底色去掉 瀏覽:463
java快遞介面 瀏覽:397
哪個app可以教新爸爸 瀏覽:210
如何查看伺服器系統版本信息 瀏覽:524
成都市土地出讓金演算法 瀏覽:702
鋼筋加密標記 瀏覽:576
ps中擴展功能在文件夾的什麼位置 瀏覽:904
雙極壓縮機為什麼要先高壓 瀏覽:527
蘋果手機伺服器填什麼 瀏覽:832
android移動動畫效果 瀏覽:691
電子和伺服器是什麼意思 瀏覽:692
phpurl中文亂碼問題 瀏覽:893
程序員那麼可愛大結局陸漓產子 瀏覽:538
java如何從雲伺服器讀取本地文件 瀏覽:924
壓縮空氣軟管製作方法 瀏覽:912
天河三號演算法 瀏覽:926
php隊列教程 瀏覽:634