blacktusk--期待收獲的季節
導航
C++博客
首頁
新隨筆
聯系
聚合
管理
<
2025年6月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
統計
隨筆 - 23
文章 - 63
評論 - 61
引用 - 0
常用鏈接
我的隨筆
我的評論
我參與的隨筆
留言簿
(6)
給我留言
查看公開留言
查看私人留言
隨筆檔案
2008年5月 (2)
2008年4月 (1)
2008年3月 (1)
2008年2月 (1)
2007年12月 (2)
2007年11月 (3)
2007年10月 (7)
2007年9月 (6)
文章分類
ACM(1)
(rss)
c++ premier(第四版中文版)(1)
(rss)
FTP搜索(3)
(rss)
linux使用解決指南(20)
(rss)
數據結構(10)
(rss)
算法導論(2)
(rss)
雜談(1)
(rss)
文章檔案
2008年7月 (1)
2008年5月 (3)
2008年3月 (4)
2008年2月 (3)
2007年12月 (4)
2007年11月 (5)
2007年10月 (20)
2007年9月 (3)
2007年6月 (15)
2007年5月 (5)
收藏夾
.net(2)
(rss)
acm(2)
(rss)
c++(3)
(rss)
值得我學習的c++博客
&豪
ACM
EEXPRESS 的ubuntu blog
lee7
vectordu
陳陳的c++博客
楓之羽
極風炫影
梁兄
農夫三拳
秦歌的c++博客
石頭的ubuntu blog
未知
小果子
憶熵
重劍無峰,大巧不工
搜索
最新評論
1.?re: gdb和g++的簡單使用
fuck the prog```
--123123
2.?re: 杭州電子科技大學acm1002:大數相加
寫的灰常優美啊~
--露露護衛隊
3.?re: 乒乓球比賽問題:兩個乒乓球隊進行比賽,各出3人,甲隊為A,B,C三人,乙隊為x,y,z三人,列出所有的對戰情況
錯誤的答案阿
--徐娟
4.?re: gdb和g++的簡單使用
感覺帖主是寫JAVA出身的
--已閱
5.?re: gdb和g++的簡單使用[未登錄]
評論內容較長,點擊標題查看
--菜鳥
閱讀排行榜
1.?大數相乘的速算思路(1011)
2.?終于有了小項目(825)
3.?打乒乓球有感(774)
4.?終于搞定了unbuntu的基本安裝(686)
5.?開始看算法導論(642)
評論排行榜
1.?徹底放棄了windows(11)
2.?國慶10.1七天計劃(10)
3.?終于有了小項目(5)
4.?強敵出現(4)
5.?開始看算法導論(4)
編寫的第一個稍微大點的程序:學生成績管理系統(線性表版)
#include
<
iostream.h
>
#include
<
stdlib.h
>
const
int
max
=
5
;
class stu
{
private
:
int
length;
int
result[max];
public
:
stu (
int
length
=
0
){}
~stu(){}
void input();
//
輸入函數
void output()
const
;
//
輸出函數
char
*
insert();
//
插入函數
char
*
remove();
//
刪除函數
void search()
const
;
//
順序查找
void sort();
//
排序函數
};
void stu::input()
{
cout
<<
"
開始建立順序表,請輸入學生成績表中學生的人數:
"
;
cin
>>
length;
cout
<<
endl;
if
(length
<=
0
||length
>
max)
{
cerr
<<
"
學生成績表的長度范圍輸入錯誤!
"
<<
endl;
exit
(
1
);
}
for
(
int
i
=
0
;i
<
length;i
++
)
{
cout
<<
"
請輸入第
"
<<
i
+
1
<<
"
學生的成績:
"
;
cin
>>
result[i];
}
}
void stu::output()
const
{
if
(length
<=
0
)
{
cerr
<<
"
學生成績表為空!
"
<<
endl;
exit
(
1
);
}
for
(
int
i
=
0
;i
<
length;i
++
)
{
cout
<<
"
第
"
<<
i
+
1
<<
"
個學生的成績是:
"
<<
result[i]
<<
endl;
}
}
char
*
stu::insert()
{
if
(length
==
max)
{
cerr
<<
"
學生成績表滿,不能插入!
"
;
exit
(
1
);
}
int
i
=
0
;
//
要插入學生成績的位置
cout
<<
"
請輸入要插入學生成績的位置:
"
;
cin
>>
i;
cout
<<
endl;
cout
<<
endl;
if
(i
<
0
||i
>
length)
{
cerr
<<
"
插入位置不合理!
"
<<
endl;
exit
(
1
);
}
cout
<<
"
請輸入要插入學生的成績:
"
;
int
temp
=
0
;
//
要插入學生的成績
cin
>>
temp;
cout
<<
endl;
for
(
int
j
=
length
-
1
;j
>=
i;j
--
)
{
result[j
+
1
]
=
result[j];
}
result[i]
=
temp;
length
++
;
return
"
插入成功\n
"
;
}
char
*
stu::remove()
{
if
(length
==
0
)
{
cerr
<<
"
學生成績表為空,不能刪除!
"
;
exit
(
1
);
}
int
i
=
0
;
//
要刪除學生成績的位置
cout
<<
"
請輸入要刪除學生成績的位置:
"
;
cin
>>
i;
cout
<<
endl;
if
(i
<
0
||i
>
length
-
1
)
{
cerr
<<
"
不存在要刪除學生的位置!
"
;
exit
(
1
);
}
//
int
temp
=
result[i
-
1
];
//
將要被刪除的學生成績存入一個臨時變量
for
(
int
j
=
i;j
<
length;j
++
)
result[j]
=
result[j
+
1
];
length
--
;
return
"
刪除成功\n
"
;
}
void stu::search()
const
{
if
(length
==
0
)
{
cerr
<<
"
學生成績表為空!
"
;
exit
(
1
);
}
int
temp
=
0
;
cout
<<
"
請輸入要查詢學生成績的成績:
"
;
cin
>>
temp;
cout
<<
endl;
for
(
int
i
=
0
;i
<
length;i
++
)
if
(result[i]
==
temp)
{
cout
<<
"
查找成功!您查找的成績在學生成績表的第
"
<<
i
<<
"
個位置
"
<<
endl;
break;
}
cout
<<
"
查找失敗!
"
<<
endl;
}
void stu::sort()
{
int
temp
=
0
;
for
(
int
i
=
0
;i
<
length
-
1
;i
++
)
{
int
k
=
i;
for
(
int
j
=
i
+
1
;j
<
length;j
++
)
if
(result[k]
>=
result[j]) k
=
j;
if
(k!
=
i)
{
temp
=
result[k];
result[k]
=
result[i];
result[i]
=
temp;
}
}
cout
<<
"
排序完成
"
<<
endl;
for
(i
=
0
;i
<
length;i
++
)
cout
<<
result[i]
<<
endl;
}
int
menu()
{
cout
<<
"
************************* 學生成績管理系統(線性表) ****************************
"
<<
endl;
cout
<<
"
* *
"
<<
endl;
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
<<
"
*******************************************************************************
"
<<
endl;
int
choice
=
0
;
cout
<<
"
請選擇動作:
"
;
cin
>>
choice;
cout
<<
endl;
return choice;
}
void main()
{
stu student;
bool
exit
=
false
;
int
choice
=
menu();
while
(
true
)
{
switch(choice)
{
case
1
:student.input();break;
case
2
:student.insert();break;
case
3
:student.remove();break;
case
4
:student.search();break;
case
5
:student.sort();break;
case
6
:student.output();break;
case
7
:
exit
=
true
;break;
}
if
(
exit
==
true
)
break;
cout
<<
endl;
cout
<<
"
請繼續選擇動作:
"
;
cin
>>
choice;
cout
<<
endl;
}
}
posted on 2007-09-23 17:32
heidaizx
閱讀(1113)
評論(0)
編輯
收藏
引用
只有注冊用戶
登錄
后才能發表評論。
【推薦】100%開源!大型工業跨平臺軟件C++源碼提供,建模,組態!
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
Powered by:
C++博客
Copyright © heidaizx
91精品国产高清久久久久久国产嫩草
|
69国产成人综合久久精品
|
精品国产91久久久久久久a
|
久久婷婷久久一区二区三区
|
国产激情久久久久影院老熟女
|
日日狠狠久久偷偷色综合免费
|
久久久国产视频
|
国产精品一久久香蕉产线看
|
久久久99精品一区二区
|
日韩精品无码久久久久久
|
国内精品久久久久久久影视麻豆
|
欧美日韩中文字幕久久久不卡
|
四虎影视久久久免费观看
|
日本久久久久亚洲中字幕
|
合区精品久久久中文字幕一区
|
A级毛片无码久久精品免费
|
亚洲国产精品一区二区久久
|
97久久国产综合精品女不卡
|
99久久精品国产一区二区
|
91精品国产色综久久
|
久久天天躁狠狠躁夜夜网站
|
亚洲精品NV久久久久久久久久
|
久久精品国产影库免费看
|
日产精品久久久久久久
|
久久无码高潮喷水
|
久久免费观看视频
|
国产成人99久久亚洲综合精品
|
A级毛片无码久久精品免费
|
亚洲国产精品一区二区三区久久
|
久久精品视频网
|
久久精品国产只有精品2020
|
久久久久人妻一区二区三区vr
|
97久久国产综合精品女不卡
|
亚洲国产精品久久久天堂
|
一本色道久久99一综合
|
亚洲狠狠婷婷综合久久蜜芽
|
伊人久久无码精品中文字幕
|
亚洲国产成人久久综合野外
|
精品久久久一二三区
|
99久久精品国产一区二区
|
亚洲国产另类久久久精品小说
|