當前位置:編程學習大全網 - 編程語言 - Zgs編程

Zgs編程

# include & ltstdio.h & gt

# include & ltstring.h & gt

#定義N 5 //人數為5。

Struct zhigong //定義結構。

{夏爾·子明[20];

庶人境內;

char bumen[30];

int年靈;

char xing bie[10];

水心境內;

};

void manu();//調用函數

void輸入(struct zhi gong zgs[]);//輸入功能

void輸出(struct zhi gong zgs[]);//輸出功能

void搜索(struct zhi gong zgs[]);//找到函數

void庶人(結構直供zgs[]);//排序函數

主()

{結構直供zgs[100];

int choice = 0;

而(選擇!=5)

{

manu();

scanf("%d ",& amp選擇);

開關(選擇)

{案例1:輸入(zgs);打破;//調用輸入函數

案例二:輸出(zgs);打破;//調用輸出函數

案例三:搜索(zgs);打破;//調用搜索到的函數

案例4:庶人(zgs);打破;//調用排序後的函數

案例五:破;

默認:printf("請重新輸入\ n ");

}

}

返回0;//返回

}

Void manu() //調用函數

{

Printf("請輸入您想要的服務類型:\ n ");

printf(" 1-輸入員工信息\ n ");

printf(" 2-顯示員工信息\ n ");

printf(" 3-查找壹些員工信息\ n ");

printf(" 4-按工號排序員工信息\ n ");

printf(" 5-exit \ n ");

返回;//返回

}

void input(structzhi gong zs[])//輸出員工信息。

{

int I;//定義變量I。

for(I = 1;我& lt= N-1;I++) //循環

{

getchar();

Printf("請輸入員工姓名\ n ");

獲取(zgs[i]。子明);//輸入員工的姓名。

Printf("請輸入員工的工號\ n ");

scanf("%8d ",& ampzgs[i]。庶人);//輸入作業編號

getchar();

Printf("請輸入員工的部門\ n ");

獲取(zgs[i]。布門);//輸入部門

Printf("請輸入員工的年齡:\ n ");

scanf("%3d ",& ampzgs[i]。年靈);//輸入年齡

Printf("請輸入員工的性別:\ n ");

scanf("%s ",& ampzgs[i]。xing bie);//輸入性別。

Printf("請輸入員工薪資:\ n ");

scanf("%5d ",& ampzgs[i]。水心);}//輸入薪資

返回;//返回

}

void output(structzhi gong zs[])//輸出函數

{ int I;

Printf("您的員工信息表為:\ n ");

for(I = 1;我& lt= N-1;i++)

{

printf("%s ",zgs[i]。子明);

printf("%8d ",zgs[i]。庶人);

printf("%s ",zgs[i]。布門);

printf("%3d ",zgs[i]。年靈);

printf("%s ",zgs[i]。xing bie);

printf("%5d ",zgs[i]。水心);

printf(" \ n ");

}

返回;//返回

}

void search(structzhi gong zs[])//搜索函數

{

int i,k = 0;

夏爾·子明[20];

Printf("請輸入您要查詢的員工姓名:\ n ");

scanf("%s ",子明);

for(I = 1;我& lt= N-1;i++)

{{

if(strcmp(子明,zgs[i])。子明)==0)

Printf("雇員編號。:%8d,部門:%s年齡:%3d性別:%s薪資:%5d\n ",

zgs[i]。庶人,zgs[i]。布門,zgs[i]。年靈,zgs[i]。興別,zgs[i]。水心);

k++;

}

while(k==0)

Printf("對不起,沒有您要找的員工\ n ");}

返回;//返回

}

void renshu(structzhi gong zs[])//排序函數

{int i,j;

結構直供t;

for(j = 1;j & lt= N-2;J++) //排序

for(I = 1;我& lt= N-1-j;i++)

if(zgs[i].庶人& gtzgs[i+1]。庶人)

{ t = zgs[I];zgs[I]= zgs[I+1];zgs[I+1]= t;}

for(I = 1;我& lt= N-1;I++) //輸出排序結果。

Printf("姓名:%s,員工編號:%8d,部門%s,年齡%3d,性別%s,薪金%5d\n ",

zgs[i]。子明,zgs[i]。庶人,zgs[i]。布門,zgs[i]。年靈,zgs[i]。興別,zgs[i]。水心);

返回;//返回

}

  • 上一篇:2022年柳州城市職業學院附屬中專部招生簡章電話師資怎麽樣地址
  • 下一篇:從鍋爐工人到億萬富翁,科技狂人埃隆·馬斯克有著怎樣的彪悍人生?
  • copyright 2024編程學習大全網