剑灵枪手梵天手镯属性:简单的人事管理系统(程序错在哪里)

来源:百度文库 编辑:高考问答 时间:2024/05/03 06:26:32
#include <stdio.h>
#include <string.h>
#define M 80
struct ofw
{
char name[8];
char sex;
int age;
float wag;
};
struct ofw ofwo[M];
int cou;
void add();
void mod();
void del();
void sho();
main()
{
int i;
struct ofw tem;
cou=0;
int x=33,y=7;
char xx;
while(1)
{
clrscr();
gotoxy(x,y);
puts("公司人事管理系统");
gotoxy(x,y+2);
puts("1.输入新增员工");
gotoxy(x,y+3);
puts("2.修改变动员工");
gotoxy(x,y+4);
puts("3.删去辞退员工");
gotoxy(x,y+5);
puts("4.显示所有员工");
gotoxy(x,y+6);
puts("退出系统");
gotoxy(x,y+8);
puts("请选译(1,2,3,4,5):");
xx=getch();
switch(xx);
{
case '1' :clrscr();
printf("请输入姓名:");
scanf("%s",tem.name);
printf("请输入性别:");
tem.sex=getche();
printf("\n请输入年龄:");
scanf("%d",&tem.age);
printf("请输入基本工资:");
scanf("%f",&tem.wag);
add(tem);
break;
case '2' :clrscr();
printf("请输入要修改员工的序列号(0,1,2,..):");
scanf("%d",&i);
if(i<cou)
mod(i);
else
printf("该序号不存在按任意键返回主屏幕....");
getch();
break;
case '3' :clrscr();
printf("请输入要删除员工的序号(0,1,2...):");
scanf("%d",&i);
if(i<cou)
del(i);
else
printf("该序号不存在按任意键返回主屏幕....");
getch();
break;
case '4' :clrscr();
sh();
break;
case '5' :clrscr();
gotoxy(x,y+3);
printf("多谢使用再见!(按任意键退出....))");
getch();
exit(0);
default :printf("输入有误,按任意键后重新输入....");
getch();
}
void add(struct ofw n)
{
struct (ofwo[cou],name,n.name);
ofwo[cou].sex=n.sex;
ofwo[cou].age=n.age;
ofwo[cou].wag=n.wag;
cou++;
printf("增加员工完毕!按任意键返回主屏幕...");
getch();
}
void mod(i);
int i;
{
struct ofwo tem1;
printf("你要修改的员工的情况是:\n");
printf("姓名:%s 性别:%c 年龄:%2d 基本工资:%8.2f\n",ofwo[i].name,ofwo[i].sex,ofwo[i].age,ofwo[i].wag);
printf("请输入新员工的信息:\n");
printf("请输入姓名:");
scanf("%s",tem1.name);
printf("请输入性别:");
tem1.sex=getche();
printf("\n请输入年龄:");
scanf("%d",&tem1.age);
printf("请输入基本工资:");
scanf("%f",&tem1.wag);
strcpy(ofwo[cou].name,tem1.name);
ofwo[cou].sex=tem1.sex;
ofwo[cou].age=tem1.age;
ofwo[cou].wag=tem1.wag;
printf("修改完毕!按任意屏幕.....");
getch);
}
void del(i);
int i;
{
int n;
for(n=i;n<cou-1;n++)
ofwo[n]=ofwo[n+1];
cou--;
prntf("删除员工完毕!按任意键返回主屏幕....");
getch();
}
void sho()
{
int i;
printf("序号 姓名 性别 年龄 基本工资\n");
for(i=0;i<cou;i++)
printf("%3d %8s %3c %8.2f\n",ofwo[i].name,ofwo[i].sex,ofwo[i].age,ofwo[i].wag);
printf("显示完毕!按任意键返回主屏幕...");
getch();
}


#include <stdio.h>
#include <string.h>
#define M 80
struct ofw
{
char name[8];
char sex;
int age;
float wag;
};
struct ofw ofwo[M];
int cou;
void add();
void mod();
void del();
void sho();
main()
{
int i;
struct ofw tem;
int x=33;
int y=7;
char xx,ch;
cou=0;
while(1)
{
clrscr();
gotoxy(x,y);
puts("公司人事管理系统");
gotoxy(x,y+2);
puts("1.输入新增员工");
gotoxy(x,y+3);
puts("2.修改变动员工");
gotoxy(x,y+4);
puts("3.删去辞退员工");
gotoxy(x,y+5);
puts("4.显示所有员工");
gotoxy(x,y+6);
puts("5.退出系统");
gotoxy(x,y+8);
puts("请选译(1,2,3,4,5):");
gotoxy(x+18,y+8);
xx=getch();
switch(xx)
{
case '1' :clrscr();
printf("请输入姓名:");
scanf("%s",tem.name);
printf("请输入性别:");
tem.sex=getche();
printf("\n请输入年龄:");
scanf("%d",&tem.age);
printf("请输入基本工资:");
scanf("%f",&tem.wag);
add(tem);
break;
case '2' :clrscr();
printf("请输入要修改员工的序列号(0,1,2,..):");
scanf("%d",&i);
if(i<cou)
mod(i);
else
printf("该序号不存在按任意键返回主屏幕....");
getch();
break;
case '3' :clrscr();
printf("请输入要删除员工的序号(0,1,2...):");
scanf("%d",&i);
if(i<cou)
del(i);
else
printf("该序号不存在按任意键返回主屏幕....");
getch();
break;
case '4' :clrscr();
sho();
break;
case '5' :clrscr();
gotoxy(x,y+3);
printf("按E(e)退出....))");
ch=getch();
if(ch=='e'||ch=='E')
exit(0);
default :printf("输入有误,按任意键后重新输入....");
getch();
}
}
}

void add(struct ofw n)
{
strcpy (ofwo[cou].name,n.name);
ofwo[cou].sex=n.sex;
ofwo[cou].age=n.age;
ofwo[cou].wag=n.wag;
cou++;
printf("增加员工完毕!按任意键返回主屏幕...");
getch();
}
void mod(i)
int i;
{
struct ofw tem1;
printf("你要修改的员工的情况是:\n");
printf("姓名:%s 性别:%c 年龄:%2d 基本工资:%8.2f\n",ofwo[i].name,ofwo[i].sex,ofwo[i].age,ofwo[i].wag);
printf("请输入新员工的信息:\n");
printf("请输入姓名:");
scanf("%s",tem1.name);
printf("请输入性别:");
tem1.sex=getche();
printf("\n请输入年龄:");
scanf("%d",&tem1.age);
printf("请输入基本工资:");
scanf("%f",&tem1.wag);
strcpy(ofwo[cou].name,tem1.name);
ofwo[cou].sex=tem1.sex;
ofwo[cou].age=tem1.age;
ofwo[cou].wag=tem1.wag;
printf("修改完毕!按任意屏幕.....");
getch();
}
void del(i)
int i;
{
int n;
for(n=i;n<cou-1;n++)
ofwo[n]=ofwo[n+1];
cou--;
printf("删除员工完毕!按任意键返回主屏幕....");
getch();
}
void sho()
{
int i;
printf("职工号 姓名 性别 年龄 基本工资\n");
for(i=0;i<cou;i++)
printf("%3d %5s %3c %5d %8f\n",ofwo[i].num,ofwo[i].name,ofwo[i].sex,ofwo[i].age,ofwo[i].wag);
printf("显示完毕!按任意键返回主屏幕...");
getch();
}


你的程序写的太混乱了