为了账号安全,请及时绑定邮箱和手机立即绑定

求c语言大佬帮忙查错

求c语言大佬帮忙查错

C
慕前端9283161 2017-06-12 17:31:35
#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> #include <malloc.h> struct wokers /*定义结构体*/ { int ID;//工号 char Name[20];//姓名 int Age;//年龄 int Worktime;//工龄 char Sex[20];//性别 char Marrige[20];//婚姻状况 int Grade;//级别1-5 int Wage;//工资 char Tired[20];//是否在职 }; typedef struct node { struct wokers data; struct node *next;//建立一个链表 }Node; void menu(Node *woker); void input(Node *woker); void amend(Node *woker); void Disp(Node *woker); void main(Node *woker) { int key; int i; printf("\n\n\n\n\t\t\t欢迎进入职工管理系统\n"); /*验证界面*/ for (i = 1; i <= 3; i++) { printf("\n\n\t\t\t请输入密码:"); scanf("%d", &key); if (key == 1234) { menu(woker); break; } printf("密码错误,请重新输入!"); } printf("密码输入三次有误!系统锁定!"); } void menu(Node *woker) { int flag, w; char c; Node *p, *q; woker = (Node *)malloc(sizeof(Node)); woker->next = NULL; p = woker; system("cls"); printf(" ************欢迎进入职工信息管理系统**********\n"); printf(" * 1.创建职工信息 2.查询职工信息 *\n"); printf(" * 3.修改职工信息 4.添加职工信息 *\n"); printf(" * 5.删除职工信息 6.排序至关信息 *\n"); printf(" * 7.修改管理员口令 8.退出程序 *\n"); printf(" ********************谢谢使用******************\n"); printf("\n"); printf("请输入你的选择1-8\n"); scanf("%d", &flag); switch (flag) { case 1:input(woker); break;//创建职工信息 case 2:Disp(woker); break;//查询职工信息 case 3:amend(woker); break;//修改职工信息 /*case 4:add(); break;//添加职工信息 case 5:delet(); break;//删除职工信息 case 6:arrange(); break;//排序至关信息 case 7:changeword(); break;//修改管理员口令 case 8:output(); break;//退出程序 */ default:w = 1; break; } if (w == 1) { printf("\n>>>>>>>>>>提示:输入错误!\n"); c = getchar; } } void input(Node *woker) //创建职工信息 { char d; Node *p, *r, *s; int id,x;//工号 r = woker; s = woker->next;//使s成为第一个有用的结点 while (r->next != NULL)//使r成为最后一个节点 r = r->next;//将指针置于最末尾 while (1) { printf(">>>>>>>>>>输入0返回菜单!\n"); printf("请输入工号\n"); scanf("%d", &id); if (id == 0) { menu(woker); } p = (Node *)malloc(sizeof(Node)); p->data.ID = id; printf("输入姓名:"); //姓名 scanf("%s", &p->data.Name); printf("输入年龄:"); //年龄 scanf("%d", &p->data.Age); printf("输入工龄:"); //工龄 scanf("%d", &p->data.Worktime); printf("输入性别:"); //性别 scanf("%s", &p->data.Sex); printf("输入婚姻状况:"); //婚姻状况 scanf("%s", &p->data.Marrige); printf("输入级别:"); //级别1-5 scanf("%d", &p->data.Grade); printf("输入工资:"); //工资 scanf("%d", &p->data.Wage); printf("输入是否在职:"); //是否在职 scanf("%s", &p->data.Tired); printf("录入成功!"); p->next = NULL; r->next = p; r = p; } getch(); menu(woker); } void amend(Node *woker) { Node *p; char find[20]; if (!woker->next) { printf("\n>>>>>>>>>>提示:没有资料可以修改!\n"); return; } printf("请输入要修改的职工号:"); scanf("%s", find); p = woker->next; while (p != NULL) { if (strcmp(p->data.ID, find) == 0) //如果找到的话返回的是符合要求 break; p = p->next; } if (p) { int x; while (1) { printf("完成修改请输入0否则输入任意数再进行修改:"); scanf("%d", &x); if (x == 0) { break; } printf("请输入新职工号(原来是 %s ):", p->data.ID); scanf("%s", p->data.ID); printf("请输入新职工姓名(原来是 %s ):", p->data.Name); scanf("%s", p->data.Name); printf("请输入新职工年龄(原来是 %s ):", p->data.Age); scanf("%s", p->data.Age); printf("请输入新职工工龄(原来是 %s ):", p->data.Worktime); scanf("%s", p->data.Worktime); printf("请输入新职工性别(原来是 %s ):", p->data.Sex); scanf("%s", p->data.Sex); printf("请输入新婚姻状况(原来是 %s ):", p->data.Marrige); scanf("%s", p->data.Marrige); printf("请输入新级别(原来是 %s ):", p->data.Grade); scanf("%s", p->data.Grade); printf("请输入新职工工资(原来是 %s ):", p->data.Wage); scanf("%s", p->data.Wage); printf("请输入新在职情况(原来是 %s ):", p->data.Tired); scanf("%s", p->data.Tired); printf("\n>>>>>>>>>>提示:该项记录资料已经成功修改!\n"); } } else printf("\n>>>>>>>>>>提示:你要修改的信息不存在!\n"); getch(); menu(woker); } void Disp(Node *woker) //输出职工信息 { Node *p; p = woker->next; if (!p) { printf("\n>>>>>>>>>>提示:没有记录可以显示!\n"); return; } printf("\t\t\t\t显示结果\n"); printf("职工号 职工姓名 职工年龄 职工工龄 职工性别 婚姻状况 职工级别 职工工资 是否在职\n"); while (p) { printf("\n%-13d%-11s%-7d%-10d%-13s%-10s%-5d%-8d%-8s\n", p->data.ID, p->data.Name, p->data.Age, p->data.Worktime, p->data.Sex, p->data.Marrige, p->data.Grade, p->data.Wage, p->data.Tired); p = p->next; } }
查看完整描述

1 回答

已采纳
?
进击的学霸No1

TA贡献15条经验 获得超12个赞

我觉得代码的输入是可以有格式的像这样

#include<stdio.h>
void main()
{
printf("Hello,Boy!");
}

你这满屏的代码你自己看起来都不舒服吧

查看完整回答
1 反对 回复 2017-06-12
  • 1 回答
  • 1 关注
  • 1260 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号