C语言课程设计(3)

2020-02-21 16:10

void main() {

int a,i,s=0;

int realmoney[10]; //定义一个计算实FILE *fp;

system(\); //更换背景为湖蓝fp = fopen(\课程设计员工信息.txt\, \);

printf(\╭═════════■□■□═══╮\\n\); //菜单界面 printf(\│ 员工信息管理系统 │\\n\); printf(\╰═══■□■□══════════╯\\n\); printf(\┌─────────────—┐\\n\); printf(\│ 1. 查询信息 2. 添加员工 │\\n\); printf(\│ │\\n\); printf(\│ 3. 删除信息 4. 实发工资 │\\n\); printf(\│ │\\n\); printf(\│ 5. 费用总和 6. 工资排名 │\\n\); printf(\│ │\\n\); printf(\│ 0. 退出程序 │\\n\); printf(\└─────────────—┘\\n\);

if (setjmp(fanhuizhi)) //longjum跳到{ } {

for (i = 0; i < 10; i++)

fscanf(fp, \, &xinxi[i].gonghao, xinxi[i].name, fclose(fp); goto begin;

发工资的数组

色,字体为黑色

此处

&xinxi[i].gongzi, &xinxi[i].butie, &xinxi[i].jiangjin, &xinxi[i].shuidian, &xinxi[i].fangzu);

for (i = 0; i < 10; i++)

realmoney[i] = xinxi[i].gongzi + xinxi[i].jiangjin + xinxi[i].butie -

xinxi[i].shuidian - xinxi[i].fangzu; //计算实发工资

begin:

printf(\请您选择(0-6):\); scanf(\, &a); //序号选择 if (a >= 0 && a <= 6) //判断序号是

//程序返回开始处

否合法 }

}

system(\);

{ } else { }

printf(\请输入正确的功能序号**\\n\);

goto begin; //序号错误程switch (a) {

case 0:exit(0); break;

case 1:search(xinxi); system(\); break; case 2:add(xinxi,realmoney); system(\); break; case 3:del(xinxi); system(\); break;

case 4:real(xinxi, realmoney); system(\); break; case 5:all(xinxi, realmoney); system(\); break; case 6:rank(xinxi, realmoney); system(\); break; }

序跳回输出序号处

链表版:

// 课程设计链表.cpp : 定义控制台应用程序的入口点。 //

#include \#include #include #include #include

#include

#define LEN sizeof(struct yuangong) //宏定义

jmp_buf fanhuizhi; //定义跳跃用参数 struct yuangong //定义员工结构体 {

int gonghao; //工号 char name[10]; //名字 int gongzi; //基本工资

};

int butie; //补贴 int jiangjin; //奖金 int shuidian; //水电费 int fangzu; //房租 int realmoney; //实发工资

struct yuangong *next; //指向下一个结构体的指针

void fanhuicaidan() //定义一个返回菜单的选择函数 { 处 } int n;

struct yuangong *lianbiao() //创建链表函数 {

struct yuangong *head; struct yuangong *p1, *p2; FILE *fp;

fp = fopen(\课程设计员工信息.txt\n = 0;

p1 = p2 = (struct yuangong *)malloc(LEN); head = NULL;

while (fscanf(fp, \&p1->gonghao, p1->name, &p1->gongzi, &p1->butie, {

n = n + 1; if (n == 1)

head = p1; p2->next = p1; else

case 0:exit(0); break; } int x;

printf(\是否返回主菜单?是请按1,退出程序请按0并回车键确定:\scanf(\switch (x) {

case 1:longjmp(fanhuizhi, 0); break; //如果选1则跳跃回setjmp

&p1->jiangjin, &p1->shuidian, &p1->fangzu) == 7) //判断文件输入返回值是否为7并执行

}

}

p2 = p1;

p1 = (struct yuangong*)malloc(LEN);

p2->next = NULL;

return(head); //函

数返回值为链表头指针

void printf(struct yuangong *head) { }

void search(struct yuangong *head) //(1)查找员工信息函数 {

struct yuangong *q; int i, j = 0; q= head;

printf(\请输入想要查询员工的工号:\scanf(\while (q!= NULL) {

if (q->gonghao == i) struct yuangong *p; printf(\员工信息为:\\n\p = head;

printf(\┌──────────────────────────────────printf(\│工号 姓名 基本工资 补贴 奖金 水电 printf(\├───────────────────────────────────if (head != NULL)

do {

printf(\│%-8d%-24s%-16d%-10d%-10d%-8d%-8d│\\n\p->gonghao, p->name, p = p->next;

────────┐\\n\房租 │\\n\───────┤\\n\

p->gongzi, p->butie, p->jiangjin, p->shuidian, p->fangzu);

} while (p != NULL);

printf(\└─────────────────────────────────

─────────┘\\n\

begin1:

}

}

{ } else

q = q->next;

printf(\┌──────────────────────────────printf(\│工号 姓名 基本工资 补贴 奖金 printf(\├───────────────────────────────printf(\

%-8d%-24s%-16d%-10d%-10d%-8d%-8d

────────────┐\\n\水电 房租 │\\n\───────────┤\\n\

\\n\

printf(\└───────────────────────────────j = 1; break;

───────────┘\\n\

if (j == 0) { }

fanhuicaidan();

printf(\此员工不存在\\n\goto

begin1;

//若无此工号返回重新输入

void {

add(struct yuangong *head,int realmoney[])

//(2)添加员工信息函数

struct yuangong *p1,*p2;

yuangong *n = (yuangong *)malloc(LEN); p2 = head;

begin2: //程序返回开始处

printf(\请以下次序输入新员工的信息\\n\

printf(\工号 姓名 基本工资 补贴 奖金 水电 房租\\n\

scanf(\while ((n->gonghao > p2->gonghao)&&(p2->next!=NULL)) { }

p1 = p2; p2 = p2->next;

an,&n->fangzu);


C语言课程设计(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:化学品安全技术说明书

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: