first commit

master
刘泓麟 6 years ago
commit 3a1c34f236

@ -0,0 +1,28 @@
# Project: 课程设计:职工工资管理系统
# Makefile created by Dev-C++ 5.11
CPP = g++.exe -D__DEBUG__
CC = gcc.exe -D__DEBUG__
WINDRES = windres.exe
OBJ = main.o
LINKOBJ = main.o
LIBS = -L"E:/C语言/Dev-Cpp/Dev-Cpp/MinGW64/lib" -L"E:/C语言/Dev-Cpp/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc -g3
INCS = -I"E:/C语言/Dev-Cpp/Dev-Cpp/MinGW64/include" -I"E:/C语言/Dev-Cpp/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"E:/C语言/Dev-Cpp/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include"
CXXINCS = -I"E:/C语言/Dev-Cpp/Dev-Cpp/MinGW64/include" -I"E:/C语言/Dev-Cpp/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"E:/C语言/Dev-Cpp/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"E:/C语言/Dev-Cpp/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++"
BIN = 课程设计:职工工资管理系统.exe
CXXFLAGS = $(CXXINCS) -g3
CFLAGS = $(INCS) -g3
RM = rm.exe -f
.PHONY: all all-before all-after clean clean-custom
all: all-before $(BIN) all-after
clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CC) $(LINKOBJ) -o $(BIN) $(LIBS)
main.o: main.c
$(CC) -c main.c -o main.o $(CFLAGS)

@ -0,0 +1,368 @@
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<string.h>
void xitong ( );//系统总体框架
void shuru(FILE *);//实现输入数据
void xianshi(FILE *);//实现显示数据
void chazhao(FILE *);//实现查找数据
void shanchu(FILE *,char *s);//实现删除数据
void tongji(FILE *);//实现统计
void xiugai(char *);//实现修改数据
struct tongjishuju {//用于统计的数组
double pjgz1;//基本工资平均值
double pjgz2;//职务工资平均值
double pjgz3;//津贴平均值
double pjgz4;//医疗保险
double pjgz5;//公积金
double pjzgz;//总工资
};
struct zhigong {//职工数组
char id[3];//序号
char name[8];//名字
int jibengongzi;//基本工资
int zhiwugongzi;//职务工资
int jintie;//津贴
int yiliaobaoxian;//医疗保险
int gongjijin;//公积金
int zonggongzi;//总工资
};
void xitong( ) {//框架函数
int a,x;//a用来选择功能x用来选择打开旧文件还是新建新文件
system("mode con cols=100 lines=40");
system("color bc");
printf("\t\t\t\t ☆欢迎使用职工工资系统☆\n");
char s[20];//存储文件名字
FILE *fp=NULL;
printf("是否需要新建一个文件\n");
printf("1:是 2:否\n");
scanf("%d",&x);//选择打开旧文件还是新建新文件
TTTT://实现重新输入
if(x==2) {
printf("请输入您需要打开的文件名\n");
scanf("%s",s);
if((fp=fopen(s,"a+"))==NULL) { //判断文件是否正确打开
printf("文件打开错误,请重新输入\n");
goto TTTT; //实现重新输入
}
}
if(x==1) {
printf("请输入您需要新建的文件名\n");
scanf("%s",s);
if((fp=fopen(s,"w+"))==NULL) { //判断文件是否正确打开
printf("文件打开错误,请重新输入\n");
goto TTTT; //实现重新输入
}
}
system("cls");
printf(" 请选择您所需要的功能\n");
printf("1.输入信息 2.显示信息\n");
printf("3.修改信息 4.查找信息\n");
printf("5.删除信息 6.统计信息\n");
printf("输入其他,关闭程序\n");
scanf("%d",&a);
switch(a) { //实现各个功能
case 1://输入
system("cls");
shuru(fp);
break;
case 2://显示
system("cls");
xianshi(fp);
break;
case 3://修改
system("cls");
xiugai(s);
fclose(fp);
break;
case 4://查找
system("cls");
chazhao(fp);
break;
case 5://删除
system("cls");
shanchu(fp,s);
break;
case 6://统计
system("cls");
tongji(fp);
break;
default://关闭
exit(1);
}
}
void shuru(FILE *fp) {
int c;//实现继续和返回主菜单
printf("请输入您所需要增加的数据\n");
printf("ID号\t姓名\t基本工资\t职务工资\t津贴\t医疗保险\t公积金\n");
struct zhigong a;
scanf("%s%s%d%d%d%d%d",a.id,a.name,&a.jibengongzi,&a.zhiwugongzi,&a.jintie,&a.yiliaobaoxian,&a.gongjijin);
a.zonggongzi=a.jibengongzi+a.gongjijin+a.jintie+a.yiliaobaoxian+a.zhiwugongzi;
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d\n",a.id,a.name,a.jibengongzi,a.zhiwugongzi,a.jintie,a.yiliaobaoxian,a.gongjijin,a.zonggongzi);//将内容输入到文件中
printf("输入1:返回主界面 输入2:继续输入 输入其他:关闭程序\n");
scanf("%d",&c);
if(c==1) {
fclose(fp);
xitong( );
} else if(c==2) {
shuru(fp);
} else
fclose(fp);
}
void chazhao(FILE *fp) {
int l;//实现继续和返回主菜单
char c[20];
printf("请输入您所需要查找的数据的姓名\n");
struct zhigong a;
scanf("%s",c);//输入查找的名字
while(1) {
if(fscanf(fp,"%s%s%d%d%d%d%d%d",a.id,a.name,&a.jibengongzi,&a.zhiwugongzi,&a.jintie,&a.yiliaobaoxian,&a.gongjijin,&a.zonggongzi)==EOF)
break;
if(strcmp(c,a.name)==0) {//已找到
printf("\t%d\t%d\t%d\t%d\t%d\t%d\n",a.jibengongzi,a.zhiwugongzi,a.jintie,a.yiliaobaoxian,a.gongjijin,a.zonggongzi);
break;
}
}
if(feof(fp)!=0) {//未找到
printf("没能找到有关数据\n");
}
printf("输入1:返回主界面 输入2:继续查找 输入其他:关闭程序\n");
scanf("%d",&l);
if(l==1) {
fclose(fp);
xitong( );
} else if(l==2) {
rewind(fp);
chazhao(fp);
} else
fclose(fp);
}
void xianshi(FILE *fp) {
int l,n;//l实现继续和返回主菜单,n计人数
char c[20][8];//姓名
struct zhigong a;
int i,f=0;//i实现循环,f算总和
printf("ID号 姓名 基本工资 职务工资 津贴 医疗保险 公积金 总工资\n");
for(i=0; i<100; i++) {//一一显示
if(fscanf(fp,"%s%s%d%d%d%d%d%d",a.id,a.name,&a.jibengongzi,&a.zhiwugongzi,&a.jintie,&a.yiliaobaoxian,&a.gongjijin,&a.zonggongzi)!=EOF)
printf("%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d\n",a.id,a.name,a.jibengongzi,a.zhiwugongzi,a.jintie,a.yiliaobaoxian,a.gongjijin,a.zonggongzi);
else
break;
}
tttt://前面的功能不需要重复实现
printf("请输入您所需要查找的数据的数目\n");
scanf("%d",&n);
printf("请输入您所需要查找的数据的姓名\n");
for(i=0; i<n; i++) {
rewind(fp);//指针回到文件开始处
scanf("%s",c[i]);
while(1) {
if(fscanf(fp,"%s%s%d%d%d%d%d%d",a.id,a.name,&a.jibengongzi,&a.zhiwugongzi,&a.jintie,&a.yiliaobaoxian,&a.gongjijin,&a.zonggongzi)==EOF)
break;
if(strcmp(c[i],a.name)==0) {
printf("\t%d\t%d\t%d\t%d\t%d\t%d\n",a.jibengongzi,a.zhiwugongzi,a.jintie,a.yiliaobaoxian,a.gongjijin,a.zonggongzi);
f+=a.zonggongzi;//计数
break;
}
}
if(feof(fp)!=0) {
printf("没能找到有关数据\n");
}
}
if(n==0)
printf("平均总工资是0\n");
else
printf("平均总工资是%lf\n",(double)f/n);//算平均值
printf("输入1:返回主界面 输入2:继续查找 输入其他:关闭程序\n");
scanf("%d",&l);
if(l==1) {
fclose(fp);
xitong( );
} else if(l==2) {
rewind(fp);
goto tttt;
} else
fclose(fp);
}
void tongji(FILE *fp) {
int c,f;//f计数c实现继续和返回主菜单
int sum=0,i,q,m1=0,m2=0,m3=0;//实现循环和做和
struct tongjishuju a;
struct zhigong b[100];//收集文件的内容
printf("请选择您需要的功能\n");
printf("1,输出符合职工工资前三项之和在3000元以上、3000~2000元、2000~1000元的职工百分比\n");
printf("2.输出工资信息表及平均工资\n");
for(i=0; i<100; i++) {
if(fscanf(fp,"%s%s%d%d%d%d%d%d",b[i].id,b[i].name,&b[i].jibengongzi,&b[i].zhiwugongzi,&b[i].jintie,&b[i].yiliaobaoxian,&b[i].gongjijin,&b[i].zonggongzi)==EOF)
break;
}
f=i;
for(i=0; i<f; i++)//计算基本工资平均值
sum+=b[i].jibengongzi;
a.pjgz1=(double)sum/(f);
sum=0;
for(i=0; i<f; i++)//计算职务工资平均值
sum+=b[i].zhiwugongzi;
a.pjgz2=(double)sum/(f);
sum=0;
for(i=0; i<f; i++)//计算津贴平均值
sum+=b[i].jintie;
a.pjgz3=(double)sum/(f);
sum=0;
for(i=0; i<f; i++)//计算医疗保险平均值
sum+=b[i].yiliaobaoxian;
a.pjgz4=(double)sum/(f);
sum=0;
for(i=0; i<f; i++)//计算公积金平均值
sum+=b[i].gongjijin;
a.pjgz5=(double)sum/(f);
sum=0;
for(i=0; i<f; i++)//计算总工资平均值
sum+=b[i].zonggongzi;
a.pjzgz=(double)sum/(f);
scanf("%d",&q);
switch(q) {
case 1://计数实现统计3000元以上占比3000~2000元占比2000元~1000元占比
for(i=0; i<f; i++) {
if((b[i].jibengongzi+b[i].zhiwugongzi+b[i].jintie)>=3000)
m1++;
if((b[i].jibengongzi+b[i].zhiwugongzi+b[i].jintie)>=2000&&(b[i].jibengongzi+b[i].zhiwugongzi+b[i].jintie)<3000)
m2++;
if((b[i].jibengongzi+b[i].zhiwugongzi+b[i].jintie)<2000&&(b[i].jibengongzi+b[i].zhiwugongzi+b[i].jintie)>=1000)
m3++;
}
printf("3000元以上占%lf\n3000~2000元占%lf\n2000元~1000元占%lf\n",(double)m1/f,(double)m2/f,(double)m3/f);
break;
case 2://实现平均数计算
for(i=0; i<f; i++)
printf("%d\t%d\t%d\t%d\t%d\t%d\n",b[i].jibengongzi,b[i].zhiwugongzi,b[i].jintie,b[i].yiliaobaoxian,b[i].gongjijin,b[i].zonggongzi);
printf("各项平均数为:");
printf("%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",a.pjgz1,a.pjgz2,a.pjgz3,a.pjgz4,a.pjgz5,a.pjzgz);
}
printf("输入1:返回主界面 输入2:继续 输入其他:关闭程序\n");
scanf("%d",&c);
if(c==1) {//实现返回主菜单等功能
fclose(fp);
xitong( );
} else if(c==2) {
rewind(fp);
tongji(fp);
} else
fclose(fp);
}
void shanchu(FILE *fp,char *s) {
int d,l,i,m,z=0;//d控制循环时间l实现功能反复实现i实现循环,m实现记住删除数的数据,z判断是否找到数据
struct zhigong a[100];
char c[20];
printf("请输入您所需要删除的数据的姓名\n");
scanf("%s",c);
for(i=0; i<100; i++) {
if(fscanf(fp,"%s%s%d%d%d%d%d%d",a[i].id,a[i].name,&a[i].jibengongzi,&a[i].zhiwugongzi,&a[i].jintie,&a[i].yiliaobaoxian,&a[i].gongjijin,&a[i].zonggongzi)==EOF) {
d=i;
break;
}
if(strcmp(c,a[i].name)==0) {
m=i;
z=1;
continue;
}
}
if(z==0)
printf("没能找到有关数据\n");
if(z==1) {//重新创造一个文件,然后将除了删除的数据写入,然后将原文件删除,将新文件改名
fclose(fp);
remove(s);//删除
fp=NULL;
fp=fopen("a.txt","a+");
for(i=0; i<d; i++) {
if(i!=m)
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t",a[i].id,a[i].name,a[i].jibengongzi,a[i].zhiwugongzi,a[i].jintie,a[i].yiliaobaoxian,a[i].gongjijin,a[i].zonggongzi);
}
rename("a.txt",s);//改名
}
printf("输入1:返回主界面 输入2:继续删除 输入其他:关闭程序\n");
scanf("%d",&l);
if(l==1) {
fclose(fp);
xitong( );
} else if(l==2) {
rewind(fp);
shanchu(fp,s);
} else
fclose(fp);
}
void xiugai(char *s) {
int l,i,z=0;
long int f=0;
struct zhigong a[100];
FILE *fp;
fp=fopen(s,"r+");
char c[20];
printf("请输入您所需要修改的数据的姓名\n");
scanf("%s",c);
for(i=0; i<100; i++) {
if(i==0)
f=0;
else
f=(ftell(fp)+2);
if(fscanf(fp,"%s%s%d%d%d%d%d%d",a[i].id,a[i].name,&a[i].jibengongzi,&a[i].zhiwugongzi,&a[i].jintie,&a[i].yiliaobaoxian,&a[i].gongjijin,&a[i].zonggongzi)==EOF) {
break;
}
if(strcmp(c,a[i].name)==0) {
z=1;
break;
}
}
if(feof(fp)!=0)
printf("没能找到有关数据\n");
if(z==1) {
printf("请输出你已经修改的信息\n");
printf("请输出工号\n");
scanf("%s",a[i].id);
printf("请输出姓名\n");
scanf("%s",a[i].name);
printf("请输出基本工资\n");
scanf("%d",&a[i].jibengongzi);
printf("请输出职务工资\n");
scanf("%d",&a[i].zhiwugongzi);
printf("请输出医疗保险数额\n");
scanf("%d",&a[i].yiliaobaoxian);
printf("请输出津贴\n");
scanf("%d",&a[i].yiliaobaoxian);
printf("请输出公积金\n");
scanf("%d",&a[i].gongjijin);
a[i].zonggongzi=a[i].jibengongzi+a[i].gongjijin+a[i].jintie+a[i].yiliaobaoxian+a[i].zhiwugongzi;
rewind(fp);
fseek(fp,f,SEEK_SET);
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d",a[i].id,a[i].name,a[i].jibengongzi,a[i].zhiwugongzi,a[i].jintie,a[i].yiliaobaoxian,a[i].gongjijin,a[i].zonggongzi);
}
printf("输入1:返回主界面 输入2:继续修改 输入其他:关闭程序\n");
scanf("%d",&l);
if(l==1) {
fclose(fp);
xitong( );
} else if(l==2) {
rewind(fp);
xiugai(s);
} else
fclose(fp);
}

Binary file not shown.

@ -0,0 +1,7 @@
#include "lxhml.h"
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main( ) {
xitong( );
return 0;
}

Binary file not shown.

BIN
main.o

Binary file not shown.

@ -0,0 +1,72 @@
[Project]
FileName=课程设计:职工工资管理系统.dev
Name=课程设计:职工工资管理系统
Type=1
Ver=2
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=
IsCpp=0
Icon=
ExeOutput=
ObjectOutput=
LogOutput=
LogOutputEnabled=0
OverrideOutput=0
OverrideOutputName=
HostApplication=
UseCustomMakefile=0
CustomMakefile=
CommandLine=
Folders=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=1
CompilerSettings=0000000000000000001000000
UnitCount=2
[VersionInfo]
Major=1
Minor=0
Release=0
Build=0
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
AutoIncBuildNr=0
SyncProduct=1
[Unit1]
FileName=main.c
CompileCpp=0
Folder=
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit2]
FileName=lxhml.h
CompileCpp=0
Folder=
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=

@ -0,0 +1,13 @@
[Editor_0]
CursorCol=14
CursorRow=4
TopLine=1
LeftChar=1
[Editors]
Order=0,1
Focused=1
[Editor_1]
CursorCol=43
CursorRow=63
TopLine=31
LeftChar=1
Loading…
Cancel
Save