65,210
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <cstring>
using namespace std;
const int M=12;
const int N=12;
const int R=12;
const int SIZE=3;
struct data
{
char No[M];/*工号*/
char name[N];/*姓名*/
char condition[R];/*情况*/
};
struct data pem[SIZE];
int n;
void input()
{
int i;
for(i=0;i <=SIZE;i++)
{
cout <<"工号:" <<endl;
cin>>pem[i].No;
cout <<"姓名:" <<endl;
cin>>pem[i].name;
cout <<"情况:" <<endl;
cout <<pem[i].condition <<endl;
}
}
void display()
{
int i;
for(i=0;i <SIZE;i++)
cout <<pem[i].No <<" " <<pem[i].name <<" " <<pem[i].condition <<endl;
}
void quarry()
{
int choice;
int k,f=0;
do
{
cout <<("\n***************** < <考勤管理系统>>****************\n");
cout <<"**********1: ******************工号" <<endl;
cout <<"**********2: ****************姓名\n" <<endl;
cout <<"**********3: **************情况" <<endl;
cout <<"make a selective chioce 1 or 2\n " <<endl;
//cout < <"press anykey to qiut" < <endl;
cin>>choice;
switch(choice)
{
case 1:
{
char name[20];
cout <<"the No:" <<endl;
cin>>name;
for(k=0;k <SIZE;k++){
if(strcmp(name,pem[k].name)==0)
{
cout <<pem[k].No <<"" <<pem[k].name <<"" <<pem[k].condition <<endl;
f=1;
}
if(f=0)
{
cout <<"no exit~~~TOT" <<endl;
break;
}
break; //*
}//少个括号
}
case 2:
{
char name[20];
cout <<"the name:" <<endl;
cin>>name;
for(k=0;k <SIZE;k++){
if(strcmp(name,pem[k].name)==0)
{
cout <<pem[k].No <<"" <<pem[k].name <<"" <<pem[k].condition <<endl;
f=1;
}
if(f=0)
{
cout <<"no exit~~~TOT" <<endl;
break;
}
break;
}
}
case 3:
{
char name[20]; //应该name
cout <<"thecondition:" <<endl;
cin>>name;
for(k=0;k <SIZE;k++){
if(strcmp(name,pem[k].name)==0)
{
cout <<pem[k].No <<"" <<pem[k].name <<"" <<pem[k].condition <<endl;
f=1;
}
if(f=0)
{
cout <<"no exit~~~TOT" <<endl;
break;
}
break;
}
}
default:
cout <<"error!" <<endl;
break;
}
}while(1);
}
void deletekey(){
int k;
char newname[20];
cout <<"请输入该员工的名字!" <<endl;
cin>>newname;
cout <<"所有员工记录为: " <<endl;
display();
for(k=0;k <2;k++)
if(strcmp(newname,pem[k].name)==0)
{
cout <<"你选择的员工为:" <<endl;
cout <<pem[k].No <<"" <<pem[k].name <<"" <<pem[k].condition <<endl;
strcpy(pem[k].No,pem[k+1].No);
strcpy(pem[k].name,pem[k+1].name);
strcpy(pem[k].condition,pem[k+1].condition);
}
cout <<"员工记录删除完毕!" <<endl;
}
int main(){
void display();
void quarry();
void deletekey();
void input();
cout <<"*********************************************" <<endl;
cout <<"*************员工管理程序****************" <<endl;
cout <<"*********************************************" <<endl;
cout <<"******************欢迎使用*******************" <<endl;
cout <<"1..............................添加" <<endl;
cout <<"2..............................显示" <<endl;
cout <<"3..............................查询" <<endl;
cout <<"4..............................删除" <<endl;
cout <<"请输入您要进行的操作:" <<endl;
int choose;
cin>>choose;
while(choose!=1&&choose!=2&&choose!=3&&choose!=4)
{ cout <<"数字多也表按错吖~~~~再按遍吧 ~ 看清楚咯 ^_^" <<endl;
cin>>choose;
if(choose==1||choose==2||choose==3||choose==4)
break;
}
while(choose==1||choose==2||choose==3||choose==4)
{
switch(choose)
{
case 1: input(); break;
case 2: display(); break;
case 3: quarry(); break;
case 4: deletekey(); break;
default:
break;
}
// cout < <"请输入您要进行的操作:" < <endl;
// cin>>choose;
}
return 0;
}