資源簡介
①程序采用交互工作方式;
②數(shù)據(jù)文件按關(guān)鍵字(姓名、學號、房號)進行排序;
③ 查詢菜單: 1.按姓名查詢 2.按學號查詢 3.按房號查詢 ;
④打印任一查詢結(jié)果(可以連續(xù)操作)
需要在c:/ww/xue.txt 文件中 填寫如下內(nèi)容 方可運行此示例
201813 Yili 115 201821 Huaxi 128
代碼片段和文件信息
#include
#include
#include
#include
using?namespace?std;
const?int?max_size=1000;
const?int?n=7;
?
typedef?struct
{
????char?name[20];
????char?num[20];
????char?dnum[10];
}StudentType;
?
typedef?struct
{
????StudentType?x[max_size];
????int?length;
}StQueue;
?
void?DisPlay(StQueue?&st){
????printf(“全部的學生信息如下:\n“);
????printf(“學號\t姓名\t房號\n“);
????for(int?i=1;i<=st.length;i++)
????????printf(“%s\t%s\t%s\n“st.x[i].numst.x[i].namest.x[i].dnum);
????printf(“\n“);
????system(“pause“);
????system(“cls“);
}
?
void?Read(StQueue?&st){
????FILE?*fp;
????char?na[20]nu[20]dnu[10];
????if((fp=fopen(“C:\\ww\\xue.txt““r“))==NULL){
????????printf(“文件讀取發(fā)生錯誤!\n“);
????????return;
????}
????st.length=0;
????while(!feof(fp)){
??
評論
共有 條評論