#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct worker
{
char name[30];
int ID;
char position[15];
int salary1,salary2,salary3,salary4,salary5,salary6;
}wo[100];
void input(int ,int);
void dis(int);
void search(int);
void del(int );
void modify(int);
void author();
void add(int ,int);
void fengmian();
main()
{
int i; int M=0;
int count=0;
fengmian();
for(;;)
{ system("cls");
printf("\n");
printf("\t\t**********************************************\n");
printf("\t\t* menue \n");
printf("\t\t [1] input \n");
printf("\t\t [2] display \n");
printf("\t\t [3] search \n");
printf("\t\t [4] delete \n");
printf("\t\t [5] modify \n");
printf("\t\t [6] author \n");
printf("\t\t [7] add \n");
printf("\t\t [0] exit \n");
printf("\t\t************************************************\n");
printf("\t\t\tplease select 0-7:");
scanf("%d",&i);
system("cls");
switch(i)
{
case 1: input(&count,M);break;
case 2: dis(count);break;
case 3: search(count);break;
case 4: del(&count);break;
case 5: modify(count);break;
case 6: author();break;
case 7: add(&count,M);break;
case 0: printf("\t\t\tthank you for use!\n");system("pause");exit(0);break;
default: printf("\t\t\twrong!\n");system("pause");break;
}
getchar();
system("cls");
}
}
void input(int *count,int M)
{
int numberTemp,i,j;int ID;
if(*count>=100){printf("No room exist!\n");}
printf("\tplease input number of workers to enter:");
scanf("%d",&numberTemp);
for(i=0;i<numberTemp;i++)
{
system("cls");
printf("The NO.%d worker\n",i+1);
printf("ID:");scanf("%d",&ID);
for(j=0;j<*count;j++)
if(wo[j].ID==ID)
{printf("There is the same ID!\n");return;}
wo[i].ID=ID;
printf("name:"); scanf("%s",wo[i].name);
printf("position:");scanf("%s",wo[i].position);
printf("jbgz:"); scanf("%d",&wo[i].salary1);
printf("gwjt:"); scanf("%d",&wo[i].salary2);
printf("qtbt:"); scanf("%d",&wo[i].salary3);
printf("kcbf:"); scanf("%d",&wo[i].salary4);
wo[i].salary5=wo[i].salary1+wo[i].salary2+wo[i].salary3;
wo[i].salary6=wo[i].salary5-wo[i].salary4;
(*count)++;M++;
printf("\t\tsuccess\n");
getchar();
}
}
void add(int *count,int M)
{
int numberTemp,i,j;int ID;int p=M+1;
if(*count>=100){printf("No room exist!\n");}
printf("\tplease input number of workers to enter:");
scanf("%d",&numberTemp);
for(i=p;i<p+numberTemp;i++)
{
system("cls");
printf("The NO.%d worker\n",i+1);
printf("ID:");scanf("%d",&ID);
for(j=0;j<*count;j++)
if(ID==wo[j].ID)
{printf("There is the same ID!\n");return;}
wo[i].ID=ID;
printf("name:"); scanf("%s",wo[i].name);
printf("position:");scanf("%s",wo[i].position);
printf("jbgz:"); scanf("%d",&wo[i].salary1);
printf("gwjt:"); scanf("%d",&wo[i].salary2);
printf("qtbt:"); scanf("%d",&wo[i].salary3);
printf("kcbf:"); scanf("%d",&wo[i].salary4);
wo[i].salary5=wo[i].salary1+wo[i].salary2+wo[i].salary3;
wo[i].salary6=wo[i].salary5-wo[i].salary4;
(*count)++;M++;
printf("\t\tsuccess\n");
getchar();
}
}
void dis(int count)
{
int i;
printf("\t\tThe following is all information\n");
printf("name\tId\tpos\tjbgz\tgwbt\tqtbt\tkcbf\tyfgz\tsfgz\n");
for(i=0;i<count;i++)
{
printf("%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\n",wo[i].name,wo[i].ID,
wo[i].position,wo[i].salary1,wo[i].salary2,wo[i].salary3,wo[i].salary4,
wo[i].salary5,wo[i].salary6);
}
printf("\t\tinput enter to back\n");
getchar();
}
void search(int count) { int n,i,flag=1;int id;char name[30]; printf("\t\t1 search by name\n"); printf("\t\t2 search by ID\n"); printf("\t\tplease select 1-2:"); scanf("%d",&n); switch(n) { case 1: printf("\t\tplease input name:"); scanf("%s",name); i=0; printf("name\tId\tpos\tjbgz\tgwbt\tqtbt\tkcbf\tyfgz\tsfgz\n"); do{ if (strcmp(name,wo[i].name)==0) { printf("%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\n",wo[i].name,wo[i].ID, wo[i].salary1,wo[i].salary2,wo[i].salary3,wo[i].salary4, wo[i].salary5,wo[i].salary6); flag=0; } }while(i<count); if(flag==1) printf("\t\tnot found\n"); break; case 2: printf("\t\tplease input ID:"); scanf("%d",&id);i=0; printf("name\tId\tpos\tjbgz\tgwbt\tqtbt\tkcbf\tyfgz\tsfgz\n"); do { if (id==wo[i].ID) { printf("%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\n",wo[i].name,wo[i].ID, wo[i].salary1,wo[i].salary2,wo[i].salary3,wo[i].salary4, wo[i].salary5,wo[i].salary6); flag=0; } }while(i<count); if(flag==1) printf("\t\tnot found!\n"); break; default: printf("\t\twrong!\n"); break; } printf("\t\tinput enter to back\n"); }
void del(int *count)
{
int id;
int i,j,flag=1;
printf("\t\tplease input ID:");
scanf("%d",&id);
for(i=0;i<*count&&flag;i++)
{if(id==wo[i].ID)
{for(j=i;j<*count-1;j++)
wo[j]=wo[j+1];
flag=0;
(*count)--;
}
else
printf("\t\tnot found!");
}
}
void modify(int count)
{
int i,n;int id;
printf("\t\tplease input the ID of worker to modify:");
scanf("%d",&id);
printf("name\tId\tpos\tjbgz\tgwbt\tqtbt\tkcbf\tyfgz\tsfgz\n");
for(i=0;i<count;i++)
if(id==wo[i].ID)
{
printf("%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\n",wo[i].name,wo[i].ID,
wo[i].salary1,wo[i].salary2,wo[i].salary3,wo[i].salary4,
wo[i].salary5,wo[i].salary6);
for(;;)
{
printf("\n");
printf("\t\t*************************************************\n");
printf("\t\t* menue \n");
printf("\t\t [1] name \n");
printf("\t\t [2] position \n");
printf("\t\t [3] jbgz \n");
printf("\t\t [4] gwjt \n");
printf("\t\t [5] qtbt \n");
printf("\t\t [6] kcbf \n");
printf("\t\t [0] exit \n");
printf("\t\t************************************************\n");
printf("\t\t\tplease select 0-6:");
scanf("%d",&n);
system("cls");
switch(n)
{
case 1: printf("\tnew name:");scanf("%s",wo[i].name);break;
case 2: printf("\tnew position:");scanf("%s",wo[i].position);break;
case 3:
printf("\tnew jbgz:");scanf("%d",&wo[i].salary1);
wo[i].salary5=wo[i].salary1+wo[i].salary2+wo[i].salary3;
wo[i].salary6=wo[i].salary5-wo[i].salary4;break;
case 4:
printf("\tnew gwjt:");scanf("%d",&wo[i].salary2);
wo[i].salary5=wo[i].salary1+wo[i].salary2+wo[i].salary3;
wo[i].salary6=wo[i].salary5-wo[i].salary4;break;
case 5:
printf("\tnew qtbt:");scanf("%d",&wo[i].salary3);
wo[i].salary5=wo[i].salary1+wo[i].salary2+wo[i].salary3;
wo[i].salary6=wo[i].salary5-wo[i].salary4;break;
case 6:
printf("\tnew kcxm:");scanf("%d",&wo[i].salary4);
wo[i].salary5=wo[i].salary1+wo[i].salary2+wo[i].salary3;
wo[i].salary6=wo[i].salary5-wo[i].salary4;break;
case 0: exit(0);break;
default: printf("\t\t\twrong!\n");system("pause");break;
}
getchar();
system("cls");
}
}
}
void author() { printf("\t\t**************************************\n\n"); printf("\t\t* \n\n"); printf("\t\t \n\n"); printf("\t\t \n\n"); printf("\t\t \n\n"); printf("\t\t \n\n"); printf("\t\t*************************************\n\n"); system("pause"); }
void fengmian()
{
printf("\n\n\n");
printf("\t welcome to use the worker wage management system\n");
printf("\n\n\n");
printf("\t\t\tpress enter to continue\n");
getchar();
}
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.