提交 c6e24667 编写于 作者: Gongzi-Yu's avatar Gongzi-Yu

未完成,只是暂存一下

上级 4e4599d9
无法预览此类型文件
#include <stdio.h>
int main()
{
}
\ No newline at end of file
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++.exe build active file",
"internalConsoleOptions": "neverOpen"
}
]
}
\ No newline at end of file
{
"C_Cpp.default.intelliSenseMode": "gcc-x64",
"C_Cpp.default.compilerPath": "C:\\mingw64\\bin\\g++.exe",
"C_Cpp.default.cppStandard": "c++20",
"debug.onTaskErrors": "abort"
}
\ No newline at end of file
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++.exe build active file",
"command": "C:\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"-std=c++20",
"\"${file}\"",
"-o",
"\"${fileDirname}\\${fileBasenameNoExtension}.exe\""
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": false,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"problemMatcher": [
"$gcc"
]
}
],
"options": {
"shell": {
"executable": "${env:SystemRoot}\\System32\\cmd.exe",
"args": [
"/c"
]
},
"env": {
"Path": "C:\\mingw64\\bin:${env:Path}"
}
}
}
\ No newline at end of file
#include <stdio.h>
typedef struct {
char xh[10];
char xm[10];
char xb[3];
int nl;
}Student;
int main()
{
FILE *fp;
int i;
Student stu[10] = {{"161910303","张三","M",18},{"161910333","李四","M",18},{"161910888","王二","F",18},
{"161910888","王二","F",38},{"164567888","规范","F",88},{"165647888","过火","F",38}},stu1={"161534338","南航","F",18},stu2,stu3[10];
fp=fopen("my.dat","wb");
fwrite(&stu,sizeof(stu),1,fp); // 写1个结构
for (i=0;i<10;i++) fwrite(&stu[i],sizeof(Student),1,fp); // 写10个结构
fclose(fp);
fp=fopen("my.dat","rb");
fread(&stu2,sizeof(Student),1,fp); // 读1个结构
for (i=0;i<10;i++) fread(&stu3[i],sizeof(Student),1,fp); // 读 10个结构
fclose(fp);
}
\ No newline at end of file
#include <stdio.h>
typedef struct
{
char xh[10];
char xm[20];
char xb[3];
int nl;
}Student;
typedef struct
{
char kh[10];
char km[25];
float xf;
}Course;
typedef struct
{
char xh[10];
char kh[10];
float cj;
}Select;
typedef struct
{
char xh[10];
char xm[20];
float cj[30];
float zpj;
float zxf;
}Score;
void instud(Student slist[],int count)
{
FILE *fp;
char studentname[20];
int i;
printf("Pealse input studentname:\n");
scanf("%s",studentname);
fp = fopen(studentname, "r");
if(fp==NULL) fp = fopen("de_student.dat","r");
for (i=0;i<count;i++) fread(&slist[i],sizeof(Student),1,fp);
fclose(fp);
}
void incourse(Course clist[],int count)
{
FILE *fp;
char coursename[20];
int i;
printf("Pealse input coursename:\n");
gets(coursename);
fp = fopen(coursename, "r");
if(fp==NULL) fp = fopen("de_course.txt","r");
for (i=0;i<count;i++) fread(&clist[i],sizeof(Course),1,fp);
fclose(fp);
}
void incjlist(Score sclist[],int count)
{
FILE *fp;
char scorename[20];
int i;
printf("Pealse input studentname:\n");
gets(scorename);
fp = fopen(scorename, "r");
if(fp==NULL) fp = fopen("de_scorse.txt","r");
for (i=0;i<count;i++) fread(&sclist[i],sizeof(Score),1,fp);
fclose(fp);
}
\ No newline at end of file
#include <stdio.h>
typedef struct
{
char xh[10];
char xm[10];
char xb[3];
int nl;
}Student;
typedef struct
{
char kh[10];
char km[25];
float xf;
}Course;
typedef struct
{
char xh[10];
char kh[10];
float cj;
}Select;
typedef struct
{
char xh[10];
char xm[20];
float cj[30];
float zpj;
float zxf;
}Score;
void instud(Student slist[], int count)
{
FILE* fp;
char studentname[20];
int i;
printf("Pealse input studentname:\n");
gets(studentname);
if ((fp = fopen(studentname, "rb")) == NULL) fp = fopen("de_student.dat", "rb");
for (i = 0; i < count; i++) fread(&slist[i], sizeof(Student), 1, fp);
fclose(fp);
}
void incourse(Course clist[], int count)
{
FILE* fp;
char coursename[20];
int i;
printf("Pealse input coursename:\n");
gets(coursename);
fp = fopen(coursename, "rb");
if (fp == NULL) fp = fopen("de_course.dat", "rb");
for (i = 0; i < count; i++) fread(&clist[i], sizeof(Course), 1, fp);
fclose(fp);
}
void incjlist(Score sclist[], int count)
{
FILE* fp;
char scorename[20];
int i;
printf("Pealse input studentname:\n");
gets(scorename);
fp = fopen(scorename, "rb");
if (fp == NULL) fp = fopen("de_scorse.dat", "rb");
for (i = 0; i < count; i++) fread(&sclist[i], sizeof(Score), 1, fp);
fclose(fp);
}
void disp_stud(Student slist[],int count)
{
int i;
for(i=0;i<count; i++)
{
printf("%s\t%s\t%s\t%d\n",slist[i].xh,slist[i].xm,slist[i].xb,slist[i].nl);
}
}//输出的结果总是少一个,还需要多看看。
int main()
{
Student slist[10];
Course clist[10];
Select sclist[20];
Score cjlist[10];
instud(slist,10);
disp_stud(slist,10);
return 0;
}
\ No newline at end of file
文件已添加
文件已添加
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册