first commit

master
commit 1b91b5ff97

@ -0,0 +1,28 @@
# Project: ¿ÎÉè
# Makefile created by Dev-C++ 5.7.1
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
OBJ = main.o
LINKOBJ = main.o
LIBS = -L"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW32/mingw32/lib" -static-libstdc++ -static-libgcc -g3
INCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib/gcc/mingw32/4.8.1/include"
CXXINCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib/gcc/mingw32/4.8.1/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib/gcc/mingw32/4.8.1/include/c++"
BIN = ¿ÎÉè.exe
CXXFLAGS = $(CXXINCS) -g3 -std=c99
CFLAGS = $(INCS) -g3 -std=c99
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 @@
18408000218 周庆 1 1 1

@ -0,0 +1,14 @@
void menus();
void input();
void display();
void save();
int my_delete();
int alter();
void demand();
void _menus();
void end();
int login();
int password();
int cpassword();
void out();
void _menus2();

274
main.c

@ -0,0 +1,274 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <time.h>
#include <conio.h>
//#include <unistd.h>
#include "head.h"
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int num=0;//当前数组中存储的数据量
struct node{
char stnum[20];
char stname[20];
char sex[8];
int age;
char detail[100];
}student[1000];
int main(int argc, char *argv[]) {
//if(!login())return 0;
menus();
char choice;
while(1){
printf("请输入正确选项!\n");
choice=getch();
system("cls");
switch(choice){
case '1':
input();
end();
break;
case '2':
display();
break;
case '3':
printf("\a保存后将退出系统\n是否继续?\n继续则输入'Y'\n按其他任意键取消\n");
char ch;
ch=getch();
if(ch=='Y'){
save();
out();
return 0;
}
break;
case '4':
if(my_delete()!=1){
out();
return 0;
}
break;
case '5':
if(alter()!=1){
out();
return 0;
}
break;
default:
system("cls");
end();
break;
}
system("cls");
menus();
}
return 0;
}
void out()
{
system("cls");
printf("本次使用到此结束!\n即将退出程序!\n");
for(int i=3;i>0;i--){
printf("%d秒后退出程序\n",i);
Sleep(1000);
}
}
void menus()
{
printf("\t\t\t\t**********请选择系统功能选项**************\n");
printf("\t\t\t\t*--------1 学生基本信息录入--------------*\n");
printf("\t\t\t\t*--------2 学生基本信息显示--------------*\n");
printf("\t\t\t\t*--------3 学生基本信息保存--------------*\n");
printf("\t\t\t\t*---4 学生基本信息删除(此选项须输入密码)-*\n");
printf("\t\t\t\t*---5 学生基本信息修改(此选项须输入密码)-*\n");
printf("\t\t\t\t******************************************\n\n");
}
void input()
{
int n=0;
char c='0';
int falg=1;
printf("请输入你要录入的学生信息数:\n");
do{
c=getch();
if(c>'9'||c<'0'){
printf("数值非法!!!\n请重新输入!\n");
}
}while(c>'9'||c<'0');
n=c-'0';
printf("你选择录入%d名学生\n",n);
if(num+n+1>=1000){
printf("本次录入只能录入%d名学生\n",1000-num-1);
falg=0;
}
for(int i=num;i<n+num;i++){
if(i==num)printf("请输入学生基本信息!\n");
if(!falg){
printf("您还可以录入%d名学生",1000-i-1);
scanf("%s %s %s %d %s",&student[i].stnum,&student[i].stname,&student[i].sex,&student[i].age,&student[i].detail);
}else{
scanf("%s %s %s %d %s",&student[i].stnum,&student[i].stname,&student[i].sex,&student[i].age,&student[i].detail);
}
if(i!=n+num-1)printf("请输入下一名学生基本信息!\n");
}
if(!falg)num=1000;
else num+=n;
printf("录入成功!\a\n");
Sleep(1000);
}
void display()
{
struct node tem[1000];
int i=0;
printf("已保存的名学生基本信息:\n");
FILE *fp=fopen("data.txt","r");
while(fscanf(fp,"%s%s%s%d%s",tem[i].stnum,tem[i].stname,tem[i].sex,&tem[i].age,tem[i].detail)!=EOF){
printf("学号:%-12s姓名:%-8s\t性别:%-4s\t年龄:%-4d\t备注:%-4s\n",tem[i].stnum,tem[i].stname,tem[i].sex,tem[i].age,tem[i].detail);
i++;
}
fclose(fp);
end();
}
void save()
{
FILE *fp;
fp=fopen("data.txt","a+");
if(fp==NULL){
printf("文件打开失败!\n即将返回菜单\n");
return ;
}
for(int i=0;i<num;i++){
fprintf(fp,"%s\t%s\t%s\t%d\t%s\n",student[i].stnum,student[i].stname,student[i].sex,student[i].age,student[i].detail);
}
printf("已录入%d名学生基本信息\a\n",num);
Sleep(1000);
int c=fclose(fp);
if(c!=0){
printf("文件打开失败!\n");
}
}
int my_delete()
{
display();
if(password()==0)return 0;
struct node tem[1000];
FILE *fp=fopen("data.txt","r");
FILE *out=fopen("data2.txt","w");
int i=0;
char s[20];
printf("仅支持按学号删除!!\n");
printf("请输入您所要删除的信息的相关学号:");
scanf("%s",s);
while(fscanf(fp,"%s%s%s%d%s",tem[i].stnum,tem[i].stname,tem[i].sex,&tem[i].age,tem[i].detail)!=EOF){
if(strcmp(s,tem[i].stnum)!=0)fprintf(out,"%s\t%s\t%s\t%d\t%s\n",tem[i].stnum,tem[i].stname,tem[i].sex,tem[i].age,tem[i].detail);
i++;
}
fclose(fp);
fclose(out);
unlink("data.txt");
rename("data2.txt","data.txt");
printf("删除完成!\a");
Sleep(500);
system("cls");
return 1;
}
int alter()
{
display();
if(password()==0)return 0;
struct node tem[1000];
FILE *fp;
fp=fopen("data.txt","r");
FILE *ou;
ou=fopen("data2.txt","w");
int i=0;
char s[20];
char t[20];
int d;
printf("仅支持按学号修改!!\n");
printf("请输入您所要删除的信息的相关学号:");
scanf("%s",s);
system("cls");
_menus2();
printf("请选择你的选项!\n");
char cho;
cho=getch();
printf("\n请输入数据:");
switch (cho){
case '1':
scanf("%s",t);
while(fscanf(fp,"%s%s%s%d%s",tem[i].stnum,tem[i].stname,tem[i].sex,&tem[i].age,tem[i].detail)!=EOF){
if(strcmp(s,tem[i].stnum)==0)
{
fprintf(ou,"%s\t%s\t%s\t%d\t%s\n",t,tem[i].stname,tem[i].sex,tem[i].age,tem[i].detail);
printf("学号:%-12s姓名:%-8s\t性别:%-4s\t年龄:%-4d\t备注:%-4s\n",t,tem[i].stname,tem[i].sex,tem[i].age,tem[i].detail);
}
else fprintf(ou,"%s\t%s\t%s\t%d\t%s\n",tem[i].stnum,tem[i].stname,tem[i].sex,tem[i].age,tem[i].detail);
i++;
}
break;
case '2':
scanf("%s",t);
while(fscanf(fp,"%s%s%s%d%s",tem[i].stnum,tem[i].stname,tem[i].sex,&tem[i].age,tem[i].detail)!=EOF){
if(strcmp(s,tem[i].stnum)==0)
{
fprintf(ou,"%s\t%s\t%s\t%d\t%s\n",tem[i].stnum,t,tem[i].sex,tem[i].age,tem[i].detail);
printf("学号:%-12s姓名:%-8s\t性别:%-4s\t年龄:%-4d\t备注:%-4s\n",tem[i].stnum,t,tem[i].sex,tem[i].age,tem[i].detail);
}
else fprintf(ou,"%s\t%s\t%s\t%d\t%s\n",tem[i].stnum,tem[i].stname,tem[i].sex,tem[i].age,tem[i].detail);
i++;
}
break;
case '3':
scanf("%s",t);
while(fscanf(fp,"%s%s%s%d%s",tem[i].stnum,tem[i].stname,tem[i].sex,&tem[i].age,tem[i].detail)!=EOF){
if(strcmp(s,tem[i].stnum)==0)
{
fprintf(ou,"%s\t%s\t%s\t%d\t%s\n",tem[i].stnum,tem[i].stname,t,tem[i].age,tem[i].detail);
printf("学号:%-12s姓名:%-8s\t性别:%-4s\t年龄:%-4d\t备注:%-4s\n",tem[i].stnum,tem[i].stname,t,tem[i].age,tem[i].detail);
}
else fprintf(ou,"%s\t%s\t%s\t%d\t%s\n",tem[i].stnum,tem[i].stname,tem[i].sex,tem[i].age,tem[i].detail);
i++;
}
break;
case '4':
scanf("%d",&d);
while(fscanf(fp,"%s%s%s%d%s",tem[i].stnum,tem[i].stname,tem[i].sex,&tem[i].age,tem[i].detail)!=EOF){
if(strcmp(s,tem[i].stnum)==0)
{
fprintf(ou,"%s\t%s\t%s\t%d\t%s\n",tem[i].stnum,tem[i].stname,tem[i].sex,d,tem[i].detail);
printf("学号:%-12s姓名:%-8s\t性别:%-4s\t年龄:%-4d\t备注:%-4s\n",tem[i].stnum,tem[i].stname,tem[i].sex,d,tem[i].detail);
}
else fprintf(ou,"%s\t%s\t%s\t%d\t%s\n",tem[i].stnum,tem[i].stname,tem[i].sex,tem[i].age,tem[i].detail);
i++;
}
break;
default:
out();
return 1;
}
while(fscanf(fp,"%s%s%s%d%s",tem[i].stnum,tem[i].stname,tem[i].sex,&tem[i].age,tem[i].detail)!=EOF){
if(strcmp(s,tem[i].stnum)!=0)fprintf(ou,"%s\t%s\t%s\t%d\t%s\n",tem[i].stnum,tem[i].stname,tem[i].sex,tem[i].age,tem[i].detail);
i++;
}
fclose(fp);
fclose(ou);
unlink("data.txt");
rename("data2.txt","data.txt");
printf("文件修改完成!\a");
Sleep(2500);
system("cls");
return 1;
}

Binary file not shown.

BIN
main.o

Binary file not shown.

@ -0,0 +1 @@
zq19991001 1234

@ -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=0
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=head.h
CompileCpp=0
Folder=¿ÎÉè
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=

Binary file not shown.

@ -0,0 +1,29 @@
[Editors]
Focused=0
Order=1,0
[Editor_0]
Open=1
Top=1
CursorCol=2
CursorRow=101
TopLine=240
LeftChar=1
[Editor_1]
Open=1
Top=0
CursorCol=14
CursorRow=14
TopLine=1
LeftChar=1
[Editor_2]
Open=1
Top=0
CursorCol=1
CursorRow=1
TopLine=1
LeftChar=1
[Editor_3]
CursorCol=1
CursorRow=1
TopLine=1
LeftChar=1
Loading…
Cancel
Save