成绩管理系统

suan.h文件代码

#pragma once
#define  _CRT_SECURE_NO_WARNINGS
#undef UNICODE
#undef _UNICODE
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <time.h>
#include <conio.h>
#include<iostream>
#include<cstring>
#include<utility>
using namespace std;
#define MaxSize 300
/*1.按成绩总分由高到低显示所有记录。2.统计汇总(即两次考试中,校,班的各科平均分,最高分,最低分,不及格人数,第二次考试缺考名单等所有数据)。3.查询数据(即输入姓名或学号可查询该生的所有成绩与排名,最好支持模糊查询,即输入“李”可查询所有名字中含有“李”字学生的成绩;)4.修改数据。5.成绩补录。(能找出第二次缺考考生的全部名单,进行成绩补录,考试成绩自定)6.删除数据。(按学号,或按姓名删除指定记录)7.能按成绩总分降序排列然后再赋与名次(班排名与校排名),分数相同名次相同。(如果有两个第二名,则没有第三名了)8.能看到学生最近考试成绩的总分升降情况,能按进步排名进行降序排列(相对上次次考试)。9.其它功能等。(自己自由发挥)核心:增,删,查,改,导入,导出数据
*/
//学生结构体的定义
typedef struct student
{int clas;            //班级char no[14];		//学号char name[20];		//姓名double  score[6];	//六门功课的成绩double sum;			//总分int school_rank;	//校排名int class_rank;		//班排名int rises;         //班级进步int rise;        //学校进步//.......
} stud;
typedef struct
{stud data[MaxSize];int length;			//长度,学生的人数 int cla1; double scor1;          //一班现在排名最高,分数int cla2; double scor2;      //二班double maxx[6], averge[6], minn[6], que[6]; int noo[6];//分别为单科最高平均最低不及格缺考人(分)int chi;           //考试次数
}SqList;//0-5分别是一班一次,一班二次,二班一次,二班二次,校一次,校二次成绩;
SqList* L[6];
char daochuming[6][19] = { "xclass11.txt","xclass12.txt","xclass21.txt","xclass22.txt","xschoo11.txt","xschoo12.txt" };//导出文件名分别是一班一次,一班二次,二班一次,二班二次,校一次,校二次成绩;
//初始化
void InitList(SqList*& L)
{L = new SqList;L->length = 0;
}//建表 
void CreateList(SqList*& L, const char* na)
{FILE* fp;if ((fp = fopen(na, "r")) == NULL)	//用只读的方式打开文件,并让文件指针fp指向它 {printf("打开的文件不存在!");exit(0);}int i = L->length;  		//记录学生人数while (!feof(fp)){fscanf(fp, "%s%s", L->data[i].no, L->data[i].name);L->data[i].clas = L->data[i].no[10] - '0';for (int j = 0; j <= 5; j++)fscanf(fp, "%lf", &L->data[i].score[j]);i++;		//人数加1 }L->length = i - 1;fclose(fp);		//关闭文件 
}//统计汇总(即两次考试中,校,班的各科平均分,最高分,最低分,不及格人数,第二次考试缺考名单等所有数据),计算总分
void Score(SqList*& L)
{memset(L->minn, 0, sizeof(L->minn));memset(L->averge, 0, sizeof(L->averge));memset(L->noo, 0, sizeof(L->noo));memset(L->que, 0, sizeof(L->que));for (int j = 0; j < 6; j++){L->minn[j] = 101;}for (int i = 0; i < L->length; i++){L->data[i].sum = 0;for (int j = 0; j < 6; j++){L->data[i].sum += L->data[i].score[j];//计算总分if (L->data[i].score[j] < 60 && L->data[i].score[j]>0)//计算不及格人数{L->noo[j]++;}if (L->data[i].score[j] <= 0 || L->data[i].score[j] > 100)//计算缺考人数{L->que[j]++;}else{L->averge[j] += L->data[i].score[j];//计算平均分L->minn[j] = min(L->data[i].score[j], L->minn[j]);//计算单科最低分L->maxx[j] = max(L->data[i].score[j], L->maxx[j]);//计算单科最高分}}}return;
}//输出顺序表的内容
void DispList(SqList* L, char* na) //把顺序表L中的内容输出到文件na中 
{FILE* fp;if ((fp = fopen(na, "w+")) == NULL)	//用写的方式打开文件,并让文件指针fp指向它 {printf("打开的文件不存在!");exit(0);}fprintf(fp, "%-17s%-10s%6s%6s%6s%6s%6s%6s%10s%7s%7s%7s%7s%7s\n", "学号", "姓名", "数据结构", "高数", "英语", "线代", "思修", "体育", "总分", "校排名", "班排名", "校进步", "班进步", "班级");fprintf(fp, "平均成绩                 % 6.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf % \n ", L->averge[0] / (L->length - L->que[0]), L->averge[1] / (L->length - L->que[1]), L->averge[2] / (L->length - L->que[2]), L->averge[3] / (L->length - L->que[3]), L->averge[4] / (L->length - L->que[4]), L->averge[5] / (L->length - L->que[5]));fprintf(fp, "最高成绩                 % 6.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf \n ", L->maxx[0], L->maxx[1], L->maxx[2], L->maxx[3], L->maxx[4], L->maxx[5]);fprintf(fp, "最低成绩                % 6.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf \n ", L->minn[0], L->minn[1], L->minn[2], L->minn[3], L->minn[4], L->minn[5]);fprintf(fp, "不及格人数            %6d%6d%6d%6d%6d%6d\n", L->noo[0], L->noo[1], L->noo[2], L->noo[3], L->noo[4], L->noo[5]);for (int i = 0; i < L->length; i++){fprintf(fp, "%-17s%-10s", L->data[i].no, L->data[i].name);fprintf(fp, "%6.1lf%6.1lf%6.1lf%6.1lf%6.1lf%6.1lf%8.1lf%7d%7d%7d%7d%7d\n", L->data[i].score[0], L->data[i].score[1], L->data[i].score[2], L->data[i].score[3], L->data[i].score[4], L->data[i].score[5], L->data[i].sum, L->data[i].school_rank, L->data[i].class_rank, L->data[i].rise, L->data[i].rises, L->data[i].clas);}fclose(fp);
}// 交换两个学生的位置
void swap1(stud& a, stud& b)
{stud temp = a;a = b;b = temp;
}// 划分函数,用于确定分区点的位置
int partition(stud arr[], int low, int high)
{double pivot = arr[high].sum; // 选择最后一个元素作为分区点int i = low - 1;for (int j = low; j <= high - 1; j++){if (arr[j].sum >= pivot){i++;swap1(arr[i], arr[j]); // 将大于等于分区点的元素交换到左侧}}swap1(arr[i + 1], arr[high]); // 将分区点放到正确的位置return (i + 1);
}// 使用快速排序算法对学生进行排序
void quickSort(stud arr[], int low, int high)
{if (low < high){int pivot = partition(arr, low, high); // 获取分区点quickSort(arr, low, pivot - 1); // 对左子数组进行快速排序quickSort(arr, pivot + 1, high); // 对右子数组进行快速排序}
}//计算排名
void calculateRanks(SqList* list)
{int i, j, k;int rank = 1;list->data[0].school_rank = rank;for (i = 0, j = 0, k = 0; i < list->length; i++){// 计算校级排名if (list->data[i].sum < list->data[i - 1].sum){rank = i + 1;}list->data[i].school_rank = rank;// 计算班级排名if (list->data[i].clas == 0){if (list->data[i].sum == list->scor1){list->data[i].class_rank = j; j++;}else{j++; list->data[i].class_rank = j; list->cla1 = j; list->scor1 = list->data[i].sum;}}else if (list->data[i].clas == 2){if (list->data[i].sum == list->scor2){list->data[i].class_rank = k; k++;}else{k++; list->data[i].class_rank = k; list->cla2 = k; list->scor2 = list->data[i].sum;}}}
}//插入学生
void insertStudent(SqList* list, stud newStudent)
{int position;int r = 0, s = list->length - 1, mid, k = 0;while (r <= s){mid = r + (s - r) / 2;if (list->data[mid].sum > newStudent.sum)r = mid + 1;else if (list->data[mid].sum < newStudent.sum)s = mid - 1;else{k = 1;r = mid;break;}}position = r;if (position < 1 || position > list->length + 1){printf("无效的插入位置\n");return;}if (list->length >= MaxSize){printf("学生列表已满,无法插入\n");return;}list->length += 1; int clap = 0; bool t = 1;// 将插入位置及其之后的学生向后移动一位for (int i = list->length - 2; i >= position; i--){list->data[i + 1] = list->data[i];if (newStudent.sum != list->data[i + 1].sum){list->data[i + 1].school_rank += 1;if (newStudent.clas == list->data[i + 1].clas){list->data[i + 1].class_rank += 1;clap = list->data[i + 1].class_rank;if (t){if (newStudent.clas == 1)list->cla1 = list->data[i + 1].class_rank;elselist->cla2 = list->data[i + 1].class_rank;t = 0;}}}}// 在指定位置插入新学生if (newStudent.sum != list->data[position + 2].sum){newStudent.class_rank = clap - 1;newStudent.school_rank = list->data[position + 2].school_rank;}list->data[position + 1] = newStudent;printf("成功插入学生\n");
}//删除学生
int  deleteStudent(SqList*& list, string a)
{int t = 0, clas = 11;double x;// 将删除位置之后的学生向前移动一位for (int i = 0; i < list->length; i++){if (list->data[i].no == a){t = 1;x = list->data[i].sum;clas = list->data[i].clas;}if (t){list->data[i - 1] = list->data[i];if (list->data[i - 1].sum != x){list->data[i - 1].school_rank--;if (clas == list->data[i - 1].clas)list->data[i - 1].class_rank--;}}}if (t)list->length--;if (t) {printf("成功删除学生\n");return 1;}printf("没有此学生\n");return 0;
}// 修改指定学生的成绩
void modifyScore(SqList* list, stud change)
{int t = 0, clas, pai;double x;for (int i = 0; i < list->length; i++){//比较if (strcmp(change.name, list->data[i].name) == 0 || strcmp(change.no, list->data[i].no) == 0){t = 1;x = list->data[i].sum;clas = list->data[i].clas;}if (t){if (change.sum < list->data[i].sum){list->data[i - 1] = list->data[i];if (list->data[i - 1].sum != x){list->data[i - 1].school_rank--;if (clas == list->data[i - 1].clas){list->data[i - 1].class_rank--;pai = list->data[i - 1].class_rank;}}}else if (change.sum == list->data[i].sum){list->data[i] = change;}else{change.class_rank = list->data[i - 1].class_rank + 1;change.school_rank = list->data[i - 1].school_rank + 1;if (clas == 1 && change.sum > list->scor1)list->scor1 = change.sum;else if (clas == 2 && change.sum > list->scor2)list->scor2 = change.sum;}}}}//模糊查找学生
void searchStudent(SqList* list, const char* keyword)
{int found = 0;for (int i = 0; i < list->length; i++){if (strstr(list->data[i].name, keyword) != NULL || strcmp(list->data[i].no, keyword) == 0){found = 1;printf("学生姓名: %s\n", list->data[i].name);printf("学号: %s\n", list->data[i].no);printf("各科成绩:\n");for (int j = 0; j < 6; j++){printf("第%d门成绩: %.2f\n", j + 1, list->data[i].score[j]);}printf("总分: %.2f\n", list->data[i].sum);printf("校排名: %d\n", list->data[i].school_rank);printf("班排名: %d\n", list->data[i].class_rank);printf("\n");}}if (!found){printf("未找到符合条件的学生\n");}
}//精确查找1
int  searc1(SqList* list, const char* keyword)
{int found = 0;for (int i = 0; i < list->length; i++){if (strcmp(list->data[i].no, keyword) == 0){return list->data[i].school_rank;}}
}//精确查找2
int  searc2(SqList* list, const char* keyword)
{int found = 0;for (int i = 0; i < list->length; i++){if (strcmp(list->data[i].no, keyword) == 0){return list->data[i].class_rank;}}
}//查询返回学生
pair<bool, stud> searc3(SqList* list, string keyword)
{bool found = 0;pair<bool, stud>aa;aa.first = 0;for (int i = 0; i < list->length; i++){if (list->data[i].no == keyword || list->data[i].name == keyword){aa.first = 1; aa.second = list->data[i];cout << "成功";return aa;}}return aa;
}//进步名次
void jinbu(SqList* L1, SqList*& L2)
{for (int i = 0; i < L2->length; i++){int t = searc1(L1, L2->data[i].no) - L2->data[i].school_rank;L2->data[i].rise = t;//学校班级进步名次int m = searc2(L1, L2->data[i].no) - L2->data[i].class_rank;L2->data[i].rises = m;}
}//预处理
void  yuchuli(SqList*& L5)
{Score(L5);//计算总分,统计汇总(即两次考试中,校,班的各科平均分,最高分,最低分,不及格人数,第二次考试缺考名单等所有数据)quickSort(L5->data, 0, L5->length);//排序calculateRanks(L5);//排名
}

jiemian.h代码

#pragma once
#define  _CRT_SECURE_NO_WARNINGS
#undef UNICODE
#undef _UNICODE
#include <graphics.h>
#include <conio.h>
#include"suan.h"
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
#define tulen 1300
#define tude 700
typedef struct REC {int left;int top;int right;int bottom;
} REC;int xunhuan(POINT cursorPos);
int xunhuan1(MOUSEMSG cursorPos);
//按钮1
void anniu1(int x1, int y1, int x2, int y2, const char* text, REC*& Box)
{Box = new REC{ x1,y1,x2,y2 };setbkcolor(WHITE);rectangle(Box->left, Box->top, Box->right - 200, Box->bottom);settextcolor(BLACK);rectangle(Box->right - 200, Box->top, Box->right, Box->bottom);settextcolor(BLACK);settextstyle(25, 0, _T("宋体"));outtextxy(Box->left + 1, Box->top + 8, text);
}
//按钮2
void anniu2(int x1, int y1, int x2, int y2, const char* text, REC*& Box)
{Box = new REC{ x1,y1,x2,y2 };setbkcolor(WHITE);rectangle(Box->left, Box->top, Box->right - 400, Box->bottom);setbkcolor(WHITE);rectangle(Box->right - 400, Box->top, Box->right - 200, Box->bottom);setbkcolor(WHITE);rectangle(Box->right - 200, Box->top, Box->right, Box->bottom);settextcolor(BLACK);settextstyle(25, 0, _T("宋体"));outtextxy(Box->left + 1, Box->top + 8, text);
}
//初始界面
void chushimian()
{IMAGE img;loadimage(&img, "back1.png", tulen, tude);    // 替换 "back" 为你的图片文件路径putimage(0, 0, &img);rectangle(0, 0, 1300, 65);// 绘制矩形settextstyle(50, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLACK);outtextxy(450, 10, "学生成绩查询系统");//文字char a[9][20] = { "校排名","1班排名" ,"2班排名"  ,"查找成绩" ,"删除成绩" ,"修改成绩","增加学生","导入成绩","导出成绩" };for (int i = 0; i < 9; i++){rectangle(0, 65 * (i + 1), 100, 65 * (i + 2));// 绘制矩形settextstyle(18, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLACK);outtextxy(20, 65 * (i + 1) + 20, a[i]);}//文字rectangle(0, 65 * (9 + 1), 100, 700);// 绘制矩形settextstyle(18, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLACK);outtextxy(20, 65 * (9 + 1) + 20, "关闭");
}
//初始控制界面
int  kongzhi()
{int t = 0;while (true) {if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) {// 检测鼠标左键按下事件POINT cursorPos;GetCursorPos(&cursorPos);for (int i = 1; i <= 9; i++)if (cursorPos.x > 0 && cursorPos.x < 100 && cursorPos.y >65 * i && cursorPos.y < 65 * (i + 1)) {if (i <= 9){cout << i;return i;}return 0;}}if (_kbhit()) {// 检测键盘按键事件char key = _getch();if (key == 27) {  // 按下Esc键退出循环break;}}}return t;
}// 绘制按钮
int Button(int x1, int y1, int x2, int y2, const char* text, int keys) {rectangle(x1, y1, x2, y2);settextstyle(25, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLACK);outtextxy(x1 + 5, y1 + 10, text);int key = 0;while (true) {if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) {// 检测鼠标左键按下事件POINT cursorPos;GetCursorPos(&cursorPos);int rr=xunhuan(cursorPos);//cin >> key;if (!rr)return 0;if (cursorPos.x > x1 && cursorPos.x < x2 && cursorPos.y >y1 && cursorPos.y < y2 || key == 123) {key = 123;cout << key;return key;}//cout << key;// Sleep(1);}}return key;
}
//下一页
void drawPage(const char* text, int pageStartIndex, int pageLength, SqList*& L1)
{// 清空窗口cleardevice();chushimian();settextstyle(15, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(103, 70, text + pageStartIndex);char gg[200];sprintf(gg, "平均成绩%25.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf \n ", L1->averge[0] / (L1->length - L1->que[0]), L1->averge[1] / (L1->length - L1->que[1]), L1->averge[2] / (L1->length - L1->que[2]), L1->averge[3] / (L1->length - L1->que[3]), L1->averge[4] / (L1->length - L1->que[4]), L1->averge[5] / (L1->length - L1->que[5]));settextstyle(15, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(103, 16 + 70, gg);sprintf(gg, "最高成绩%26.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf \n ", L1->maxx[0], L1->maxx[1], L1->maxx[2], L1->maxx[3], L1->maxx[4], L1->maxx[5]);settextstyle(15, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(103, 32 + 70, gg);// 绘制页码sprintf(gg, "最低成绩% 25.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf % 6.1lf \n ", L1->minn[0], L1->minn[1], L1->minn[2], L1->minn[3], L1->minn[4], L1->minn[5]);settextstyle(15, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(103, 16 + 32 + 70, gg);// 绘制页码sprintf(gg, "不及格人数%20d%6d%6d%6d%6d%6d\n", L1->noo[0], L1->noo[1], L1->noo[2], L1->noo[3], L1->noo[4], L1->noo[5]);settextstyle(15, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(103, 64 + 70, gg);// 绘制页码settextcolor(BLACK);char pageNumText[16];sprintf_s(pageNumText, "Page: %d", (pageStartIndex / pageLength) + 1);setbkmode(TRANSPARENT);outtextxy(103, 680, pageNumText);for (int j = 0, i = pageStartIndex * 32; i < (pageStartIndex + 1) * 32; i++, j++){if (i == L1->length)break;char student[200];sprintf(student, "%-17s%-10s%6.1lf%6.1lf%6.1lf%6.1lf%6.1lf%6.1lf%6.1lf%6d%6d%6d%6d\n", L1->data[i].no, L1->data[i].name, L1->data[i].score[0], L1->data[i].score[1], L1->data[i].score[2], L1->data[i].score[3], L1->data[i].score[4], L1->data[i].score[5], L1->data[i].sum, L1->data[i].school_rank, L1->data[i].class_rank, L1->data[i].rises, L1->data[i].clas);settextstyle(15, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(103, 16 * 4 + 85 + 16 * j, student);}
}
//排名界面
void jiemian2(int x)
{//const char* longText = "This is a long text. It can span across multiple pages in the graphics window. Press 'Enter' to go to the next page.";char studentInfo[100];sprintf(studentInfo, "%-17s%-10s%6s%6s%6s%6s%6s%6s%6s%8s%7s%7s%7s\n", "学号", "姓名", "数据结构", "高数", "英语", "线代", "思修", "体育", "总分", "校排名", "班排名", "上升名", "班级");/*settextstyle(6, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(105, 70, studentInfo);*/const char* longText = studentInfo;int pageStartIndex = 0;int pageLength = 1;// outtextxy(103, 680, pageNumText);while (true) {drawPage(longText, pageStartIndex, pageLength, L[x]);// 等待用户按下键盘事件/*const int buttonX1 = 180;const int buttonY1 = 670;const int buttonX2 = 228;const int buttonY2 = 695;const char* buttonText = "下一页";*/int key = 0;key = Button(900, 630, 1000, 680, "下一页", 123);if (key == 0)return;settextstyle(15, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLACK);outtextxy(183, 680, "下一页按enter");if (key == 123) { // 切换到下一页pageStartIndex += pageLength;if (pageStartIndex >= (L[x]->length + 31) / 32) {pageStartIndex = 0; // 已经到达文本末尾,重新从第一页开始}}//panduan();}
}// 模糊查找学生
void searchStudent1(SqList* list, const std::string& keyword)
{int found = 0;int x1 = 102, y1 = 180;if (keyword.size() == 0){printf("未找到符合条件的学生\n");settextstyle(15, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(x1, y1, "未找到符合条件的学生\n");return;}for (int i = 0; i < list->length; i++){if (strstr(list->data[i].name, keyword.c_str()) != NULL || list->data[i].no == keyword){found = 1;char student[200];sprintf(student, "%-17s%-10s%6.1lf%6.1lf%6.1lf%6.1lf%6.1lf%6.1lf%6.1lf%6d%6d%6d%6d\n", list->data[i].no, list->data[i].name, list->data[i].score[0], list->data[i].score[1], list->data[i].score[2], list->data[i].score[3], list->data[i].score[4], list->data[i].score[5], list->data[i].sum, list->data[i].school_rank, list->data[i].class_rank, list->data[i].rises, list->data[i].clas);settextstyle(15, 0, _T("宋体"));setbkmode(WHITE);settextcolor(BLUE);outtextxy(x1, y1, student);printf("学生姓名: %s\n", list->data[i].name);printf("学号: %s\n", list->data[i].no);printf("各科成绩:\n");for (int j = 0; j < 6; j++){printf("第%d门成绩: %.2f\n", j + 1, list->data[i].score[j]);}printf("总分: %.2f\n", list->data[i].sum);printf("校排名: %d\n", list->data[i].school_rank);printf("班排名: %d\n", list->data[i].class_rank);printf("\n");y1 += 16;}}if (!found){printf("未找到符合条件的学生\n");settextstyle(15, 0, _T("宋体"));setbkmode(WHITE);settextcolor(BLUE);outtextxy(x1, y1, "未找到符合条件的学生\n");}
}
//按钮
char* Button1(int x1, int y1, int x2, int y2, const char* xx) {rectangle(x1, y1, x2, y2);rectangle(700, 120, 800, 170);settextstyle(25, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLACK);outtextxy(700 + 5, y1 + 10, xx);static char aa[35];  // 使用静态数组while (true) {if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) {// 检测鼠标左键按下事件POINT cursorPos;GetCursorPos(&cursorPos);int rr=xunhuan(cursorPos);if (!rr)return 0;if (cursorPos.x > x1 && cursorPos.x < x2 && cursorPos.y >y1 && cursorPos.y < y2) {std::cin >> aa;settextstyle(25, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLACK);outtextxy(x1 + 5, y1 + 10, aa);return aa;}}}return aa;
}
//搜索界面
void  sousuo()
{chushimian();char* aa = Button1(200, 120, 700, 170, "搜索");if (aa == 0)return;int x1 = 700, y1 = 120, x2 = 780, y2 = 170;// 创建搜索按钮int key = 0;while (true) {if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) {// 检测鼠标左键按下事件POINT cursorPos;GetCursorPos(&cursorPos);// cin >> key;if (cursorPos.x > x1 && cursorPos.x < x2 + 100 && cursorPos.y >y1 - 20 && cursorPos.y < y2 + 20) {key = 123;printf("Input box selected.\n");searchStudent1(L[5], aa);cout << key;}xunhuan(cursorPos);// Sleep(1);}}
}//删除界面
void shanchu1()
{chushimian();char* aa = Button1(200, 120, 700, 170, "删除");if (aa == 0)return;int x1 = 700, y1 = 120, x2 = 780, y2 = 170;// 创建搜索按钮int key = 0;while (true) {if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) {// 检测鼠标左键按下事件POINT cursorPos;GetCursorPos(&cursorPos);// cin >> key;if (cursorPos.x > x1 && cursorPos.x < x2 + 100 && cursorPos.y >y1 - 20 && cursorPos.y < y2 + 20) {key = 123;printf("已删除\n");//searchStudent1(L1, inputText);int tt = 0;tt = deleteStudent(L[5], aa);if (tt) {settextstyle(25, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(340, 190, "已删除");}else{settextstyle(25, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(340, 190, "没有此学生");}cout << key;xunhuan(cursorPos);}// Sleep(1);}}}//修改界面2
void change2(stud aa)
{chushimian();char b[6][15] = { "数据结构", "高数", "英语", "线代", "思修", "体育" };char a[9][55];settextcolor(BLACK);settextstyle(35, 0, _T("宋体"));outtextxy(240, 90, "将需要修改的内容重新输入到对于的输入框内");int x1 = 160, x2 = 580, y1 = 130, y2 = 180, height = 50;sprintf(a[0], "学号%s", aa.no);sprintf(a[1], "名字%s", aa.name);sprintf(a[8], "班级%d", aa.clas);for (int i = 0; i < 6; i++){sprintf(a[i + 2], "%s%.1lf", b[i], aa.score[i]);}REC* Box[10];Box[9] = new REC{ 650,150,715,200 };setbkcolor(WHITE);rectangle(Box[9]->left, Box[9]->top, Box[9]->right, Box[9]->bottom);settextcolor(RED);settextstyle(25, 0, _T("宋体"));outtextxy(Box[9]->left + 10, Box[9]->top + 8, "提交");for (int i = 0; i < 9; i++){anniu1(x1, y1, x2, y1 + height, a[i], Box[i]);y1 += height + 10;}// 监听鼠标点击事件MOUSEMSG m;while (true){m = GetMouseMsg();int rr=xunhuan1(m);if (!rr)return;// 确定当前活动的输入框int activeInput = -1;for (int i = 0; i <= 9; i++){if (m.uMsg == WM_LBUTTONDOWN &&m.x >= Box[i]->left && m.x <= Box[i]->right &&m.y >= Box[i]->top && m.y <= Box[i]->bottom){if (i < 2){char chang[20];cin >> chang;settextcolor(BLUE);settextstyle(25, 0, _T("宋体"));outtextxy(Box[i]->right - 198, Box[i]->top + 8, chang);if (i == 0)strcpy(aa.no, chang);elsestrcpy(aa.name, chang);cout << "成功";}else if (i < 9){int scaress;cin >> scaress;char changes[20];sprintf(changes, "%d", scaress);cout << changes;settextcolor(BLUE);settextstyle(25, 0, _T("宋体"));outtextxy(Box[i]->right - 198, Box[i]->top + 8, changes);if (i >= 2 && i < 8){aa.score[i - 2] = scaress;}elseaa.clas = scaress;cout << "成功";}else{modifyScore(L[5], aa);settextcolor(BLUE);settextstyle(25, 0, _T("宋体"));outtextxy(Box[9]->left, Box[9]->top + 100, "修改成功");cout << "修改成功";return;}}}}
}
//修改界面1
void change()
{chushimian();char* aa = Button1(200, 120, 700, 170, "修改学生");if (aa == 0)return;int x1 = 700, y1 = 120, x2 = 780, y2 = 170;// 创建搜索按钮int key = 0;while (true) {if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) {// 检测鼠标左键按下事件POINT cursorPos;GetCursorPos(&cursorPos);int rr = xunhuan(cursorPos);if (!rr)return;if (cursorPos.x > x1 && cursorPos.x < x2 + 100 && cursorPos.y >y1 - 20 && cursorPos.y < y2 + 20) {key = 123; int flag = 0;pair<bool, stud>tt;tt = searc3(L[5], aa);if (tt.first){change2(tt.second);flag = 1;}if (!flag){settextstyle(25, 0, _T("宋体"));setbkmode(TRANSPARENT);settextcolor(BLUE);outtextxy(340, 190, "没有此学生");}}cout << key;}// Sleep(1);}
}//增加界面
void add()
{stud aa;chushimian();char a[9][15] = { "学号","名字", "数据结构", "高数", "英语", "线代", "思修", "体育","班级" };settextcolor(BLACK);settextstyle(35, 0, _T("宋体"));outtextxy(240, 90, "将需要补录学生的信息输入到对于的输入框内");int x1 = 160, x2 = 580, y1 = 130, y2 = 180, height = 50;REC* Box[10];Box[9] = new REC{ 650,150,715,200 };setbkcolor(WHITE);rectangle(Box[9]->left, Box[9]->top, Box[9]->right, Box[9]->bottom);settextcolor(RED);settextstyle(25, 0, _T("宋体"));outtextxy(Box[9]->left + 10, Box[9]->top + 8, "提交");for (int i = 0; i < 9; i++){anniu1(x1, y1, x2, y1 + height, a[i], Box[i]);y1 += height + 10;}// 监听鼠标点击事件MOUSEMSG m;while (true){m = GetMouseMsg();int rr = xunhuan1(m);if (!rr)return;// 确定当前活动的输入框int activeInput = -1;for (int i = 0; i <= 9; i++){if (m.uMsg == WM_LBUTTONDOWN &&m.x >= Box[i]->left-10 && m.x <= Box[i]->right+20 &&m.y >= Box[i]->top && m.y <= Box[i]->bottom){if (i < 2){char chang[20];cin >> chang;settextcolor(BLUE);settextstyle(25, 0, _T("宋体"));outtextxy(Box[i]->right - 198, Box[i]->top + 8, chang);if (i == 0)strcpy(aa.no, chang);elsestrcpy(aa.name, chang);cout << "成功";}else if (i < 9){int scaress;cin >> scaress;char changes[20];sprintf(changes, "%d", scaress);cout << changes;settextcolor(BLUE);settextstyle(25, 0, _T("宋体"));outtextxy(Box[i]->right - 198, Box[i]->top + 8, changes);if (i >= 2 && i < 8){aa.score[i - 2] = scaress;}elseaa.clas = scaress;cout << "成功";}else{insertStudent(L[5], aa);settextcolor(BLUE);settextstyle(25, 0, _T("宋体"));outtextxy(Box[9]->left, Box[9]->top + 100, "增加成功");cout << "增加成功";}xunhuan1(m);}}}
}//导入界面
void daoru1()
{chushimian();char a[6][30] = { "导入一班一次成绩", "导入一班二次成绩", "导入二班一次成绩", "导入二班二次成绩","导入学校一次成绩", "导入学校二次成绩" };settextcolor(BLACK);settextstyle(35, 0, _T("宋体"));outtextxy(240, 90, "将需要导入的文件名输入到对于的输入框内");int x1 = 240, x2 = 880, y1 = 130, y2 = 180, height = 50;REC* Box[6];for (int i = 0; i < 6; i++){anniu2(x1, y1, x2, y1 + height, a[i], Box[i]);y1 += height + 10;}// 监听鼠标点击事件MOUSEMSG m;while (true){m = GetMouseMsg();int rr = xunhuan1(m);if (!rr)return;// 确定当前活动的输入框int activeInput = -1;for (int i = 0; i < 6; i++){bool t = 0;if (m.uMsg == WM_LBUTTONDOWN &&m.x >= Box[i]->left && m.x <= Box[i]->right - 200 &&m.y >= Box[i]->top && m.y <= Box[i]->bottom){char chang[20];cin >> chang;settextcolor(BLUE);settextstyle(25, 0, _T("宋体"));outtextxy(Box[i]->right - 398, Box[i]->top + 8, chang);cout << chang;InitList(L[i]);CreateList(L[i], chang);L[i]->chi = 2;yuchuli(L[i]);t = 1;if (t){settextcolor(BLUE);settextstyle(25, 0, _T("宋体"));outtextxy(Box[i]->right - 198, Box[i]->top + 8, "导入成功");cout << 123;}else{settextcolor(BLUE);settextstyle(25, 0, _T("宋体"));outtextxy(Box[i]->right - 198, Box[i]->top + 8, "导入失败");cout << 123;}}}}
}//导出界面
void daochu()
{chushimian();char a[6][30] = { "导出一班一次成绩", "导出一班二次成绩", "导出二班一次成绩", "导出二班二次成绩","导出第一次校成绩","导出第二次校成绩" };int x1 = 200, x2 = 780, y1 = 120, y2 = 170, height = 50;REC* Box[6];for (int i = 0; i < 6; i++){anniu1(x1, y1, x2, y1 + height, a[i], Box[i]);y1 += height + 10;}// 监听鼠标点击事件MOUSEMSG m;while (true){m = GetMouseMsg();int rr = xunhuan1(m);if (!rr)return;// 确定当前活动的输入框int activeInput = -1;for (int i = 0; i < 6; i++){if (m.uMsg == WM_LBUTTONDOWN &&m.x >= Box[i]->left && m.x <= Box[i]->right &&m.y >= Box[i]->top && m.y <= Box[i]->bottom){settextcolor(BLUE);settextstyle(25, 0, _T("宋体"));outtextxy(Box[i]->right - 198, Box[i]->top + 8, "导出成功");activeInput = i;DispList(L[i], daochuming[i]);break;}}}
}//初始化界面
void chushi()
{initgraph(1300, 700);  // 初始化图形窗口int tt = 111;chushimian();tt = kongzhi();//对应"校排名","1班排名" ,"2班排名"  ,"查找成绩" ,"删除成绩" ,"修改成绩","增加学生","导入成绩","导出成绩"if (tt == 1){jiemian2(5);}else if (tt == 2){jiemian2(1);}else if (tt == 3){jiemian2(3);}else if (tt == 4){sousuo();}else if (tt == 5){shanchu1();}else if (tt == 6){change();}else if (tt == 7){add();}else if (tt == 8){daoru1();}else if (tt == 9){daochu();}else if (tt == 0)closegraph();   // 关闭窗口return;
}
int xunhuan(POINT cursorPos)
{for (int i = 1; i <=10; i++)if (cursorPos.x > 0 && cursorPos.x < 100 && cursorPos.y >65 * i && cursorPos.y < 65 * (i + 1)) {if (i == 0){closegraph();return 0;}if (i == 1){jiemian2(5);return 0;}if (i == 2){jiemian2(1);return 0;}if (i == 3){jiemian2(3);return 0;}if (i == 4){sousuo();return 0;}if (i == 5){shanchu1();return 0;}if (i == 6){change();return 0;}if (i == 7){add();return 0;}if (i == 8){daoru1();return 0;}if (i == 9){daochu();return 0;}if (i == 10){closegraph();return 0;}}return 1;
}
int xunhuan1(MOUSEMSG cursorPos)
{for (int i = 1; i <= 9; i++)if (cursorPos.uMsg == WM_LBUTTONDOWN && cursorPos.x > 0 && cursorPos.x < 100 && cursorPos.y >65 * i && cursorPos.y < 65 * (i + 1)) {if (i == 0){closegraph();return 0;}if (i == 1){jiemian2(5);return 0;}if (i == 2){jiemian2(1);return 0;}if (i == 3){jiemian2(3);return 0;}if (i == 4){sousuo();return 0;}if (i == 5){shanchu1();return 0;}if (i == 6){change();return 0;}if (i == 7){add();return 0;}if (i == 8){daoru1();return 0;}if (i == 9){daochu();return 0;}}return 1;
}//录入成绩
void luru()
{InitList(L[4]);CreateList(L[4], "class1.txt");L[4]->chi = 1;yuchuli(L[4]);InitList(L[5]);CreateList(L[5], "class2.txt");L[5]->chi = 2;yuchuli(L[5]);InitList(L[1]);InitList(L[2]);InitList(L[3]);InitList(L[0]);
}
//预处理
void yu()
{luru();jinbu(L[4], L[5]);int x = 0, y = 0;for (int i = 0; i < L[4]->length; i++){if (L[4]->data[i].clas == 0){L[0]->data[x] = L[4]->data[i];x++;}else{L[2]->data[y] = L[4]->data[i];y++;}}L[0]->length = x;L[2]->length = y;x = 0, y = 0;for (int i = 0; i < L[5]->length; i++){if (L[5]->data[i].clas == 0){L[1]->data[x] = L[5]->data[i];x++;}else{L[3]->data[y] = L[5]->data[i];y++;}}L[1]->length = x;L[3]->length = y;for (int i = 0; i < 6; i++){if (i < 4)Score(L[i]);DispList(L[i], daochuming[i]);}
}

cpp文件代码

#include"suan.h"
#include"jiemian.h"
#include<iostream>
using namespace std;int main()
{yu();chushi();return 0;
}

使用说明

1.使用的visual studio

2.easyx可以在代码巴士 - 分享有价值的 C/C++ 知识和源代码中一键下载

3.背景图像命名back1.png在chushihua函数中

4.成绩有六门,文件中文字按学号 名字 成绩的顺序

5.导入成绩没做完(真的不想改了)所以用yu的函数直接导入计算了(我用的是校成绩,文件命名class1.txt和class2.txt)

6.每个地方点击一次就可以了,如果点击两次你就会发现bug了

最后就是说缺点和遇到的问题了

作为一名c语言初学者,第一次写几百行的代码(最初只是想用好看的图片背景完成作业,结果写代码时遇到了许多问题,而且代码中还有许多问题未解决)。

1.用easyx图形库时发现看完文档后几乎不会写什么(后面直接用chatgpt查询,方便许多,但是还是出现许多报错如cpt给出函数库没有,给出的代码运行太慢点击了一分钟后才能反应)

2.开始写的函数,后面调用的时候发现调用困难了,难以运用(哭泣)

3.变量命名不规范和报错了

欢迎找出bug和修正

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/68619.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

360全景热点panolens.js 实现代码

本片主要介绍360全景热点基于panolens.js 实现的代码&#xff0c;主要通过如下步骤实现&#xff1a; 1&#xff0c;引入核心js库 <script src"js/three.min.js"></script><script src"js/panolens.min.js"></script> 2&#xff0…

2020年360亿条数据遭泄露 网络安全产业风口要来了

[网络安全重磅福利&#xff1a;入门&进阶全套282G学习资源包免费分享&#xff01;](https://mp.weixin.qq.com/s/BWb9OzaB-gVGVpkm161PMw ) 数据被视为21世纪的“钻石矿”&#xff0c;蕴含着巨大的动能&#xff0c;并且具有边际效应递增的特点&#xff0c;在不断的流动共享…

360腾讯计算机比赛,巅峰对决 腾讯电脑管家VS360详尽评测

【IT168 评测】提起目前国内杀毒软件市场&#xff0c;可谓群雄割据&#xff0c;从老一批的瑞星、卡巴斯基、360&#xff0c;到近些年崛起的腾讯电脑管家似乎在杀毒界也风起云涌&#xff0c;近期业界又有消息称电脑管家获得AV-TEST认证&#xff0c;包揽了国际四大权威杀毒测试奖…

奇虎360软件阻止腾讯电脑管家启动,3Q大战将再度上演?

今天下午值班&#xff0c;使用同事的电脑上网。开机进入桌面后看见系统托盘区冒出360安全卫士和360杀毒软件的图标&#xff0c;立马全部退出。到腾讯电脑管家官网下载了安装程序进行安装。 安装程序窗口在安装进度达到99%后&#xff0c;忽然就消失了&#xff0c;系统托盘区也没…

本周大新闻|John Carmack从Meta离职,OPPO发布双目AR一体机仅38g

本周大新闻&#xff0c;AR方面&#xff0c;微软已向客户承诺新款HoloLens&#xff1b;NASA成立Joint AR项目&#xff0c;计划在宇航服头盔中加入AR功能&#xff1b;OPPO Air Glass 2发布&#xff0c;双目光波导仅38g&#xff1b;Rokid开设全球首家品牌旗舰店&#xff1b;谷歌为…

周鸿祎亲自站台,360年度新旗舰究竟有何特别?

众所周知&#xff0c;360自从推出手机之后&#xff0c;每一代产品都以高性价比著称。即便是在竞争早已趋于白热化的智能手机红海市场&#xff0c;360手机依然能够占有一席之地。 不过&#xff0c;虽然360手机已经迭代到了N7系列&#xff0c;但是“红衣教主”周鸿祎在发布会上露…

腾讯360

尊敬的360用户&#xff1a; 360推出扣扣保镖的本意&#xff0c;是为了让QQ更安全更好用。而腾讯公司的 举措让用户陷入两难&#xff0c;这有悖于我们的初衷。 为了避免让用户做两难的抉择&#xff0c;360决定暂时召回扣扣保镖产品。 对给您带来的不便&#xff0c;我们非常抱歉…

12月24日科技资讯|12306 回应软件崩了;微信发布新版本,朋友圈可“斗图”;Ant Design 3.26.4 发布

「极客头条」—— 技术人员的新闻圈&#xff01; CSDN 的读者朋友们早上好哇&#xff0c;「极客头条」来啦&#xff0c;快来看今天都有哪些值得我们技术人关注的重要新闻吧。扫描上方二维码进入 CSDN App 可以收听御姐萌妹 Style 的人工版音频哟。 一分钟速览新闻点&#xff…

360安全卫士上线新功能: 一周电脑安全动态全掌握

在互联网行业高速发展的今天&#xff0c;不管你从事何种行业&#xff0c;都离不开电脑办公&#xff0c;更不用说在生活娱乐中电脑所发挥的巨大作用&#xff0c;可以说电脑已经成了我们生活中必备的一部分。 电脑跟人类一样&#xff0c;不良的使用习惯、外来攻击都会给电脑健康…

OPPO Watch新品将于9月16日正式发布

2021 年 9 月 15 日&#xff0c;中国&#xff0c;深圳——OPPO今日宣布&#xff0c;OPPO Watch系列新款产品&#xff0c;将于 9 月 16 日在OPPO秋季新品发布会正式发布。 新款OPPO Watch将主打健康监测功能&#xff0c;可以实时监测用户的身体健康数据&#xff0c;并提供的健康…

腾讯会议发布3.0版本;微软将推出元宇宙产品;Firefox启动最大WebRTC升级|WebRTC风向

点击一键订阅《云荐大咖》专栏&#xff0c;获取官方推荐精品内容&#xff0c;学技术不迷路&#xff01; 近年来&#xff0c;实时音视频快速发展&#xff0c;WebRTC做为实时音视频的标准也快速发展&#xff0c;从直播到通讯&#xff0c;其应用场景也在不断丰富。如果您关注实时音…

360测试之美技术分享大会(第十季)圆满结束(附直播回放及PPT分享链接)

疫情居家&#xff0c;何以解忧&#xff1f;在线分享&#xff0c;也是一种不出家门可了解技术动态天下事的绝佳途径&#xff0c;对测试感兴趣的同学看过来哟~ 为了应对疫情影响&#xff0c;第十季测试之美技术分享大会于2022年12月3日上午九点半在360幕印平台准时开播。本次大会…

第六届 Techo TVP 开发者峰会暨腾讯云大数据峰会来啦

引言 50 年前&#xff0c;数据库管理系统、关系型数据库诞生&#xff0c;数据处理效率大大提升。数据库软件开始被应用于业务数据处理。20 年前&#xff0c;单机存储能力遭遇瓶颈&#xff0c;分布式存储计算架构成为主流。Apache Hadoop 成为大数据技术的代名词。 10 年前&…

360和腾讯QQ的那场战争!

阅读本文大概需要10分钟。 这是我的10年程序人生的第五篇&#xff0c;记录一场惊心动魄的商业大战&#xff1a;3Q大战。 在中国互联网历史上&#xff0c;3Q大战是标志性的一战&#xff0c;堪称互联网第一次世界大战。 彼时洋哥还是一个工作不到两年的基层员工&#xff0c;有幸…

腾讯安全威胁情报品牌发布会召开 打造开放、共享的情报生态圈

近年来&#xff0c;全球网络安全威胁态势愈发严峻&#xff0c;安全事件层出不穷&#xff0c;企业传统的安全防御策略显得越来越力不从心。如何快速高效应对持续性的网络威胁&#xff0c;构建更具实战和联动能力的威胁情报能力&#xff0c;实现安全防御上的“化被动为主动”&…

TCP连接中TIME_WAIT状态过多原因分析

1.time_wait状态过多原因 在高并发短连接的TCP服务器上&#xff0c;当服务器处理完请求后立刻主动正常关闭连接。主动关闭的一方在发送最后一个 ack 后就会进入TIME_WAIT 状态 停留2MSL&#xff08;max segment lifetime&#xff09;的时间&#xff0c;这个场景下&#xff0c;会…

服务器出现大量 TIME_WAIT,如何解决

经常在服务器发现一些连接出现 TIME_WAIT 状态&#xff0c;那么为什么会有 TIME_WAIT状态&#xff0c;它是如何产生的&#xff1f;大量的 TIME_WAIT 有什么危害&#xff1f;如何排查&#xff1f;如何优化&#xff1f;带着这些问题逐步分析&#xff1a; 1. TCP 连接回顾 TCP 创建…

【已解决】vagrant up下载box速度太慢的解决方法

文章目录 有自己思想&#xff0c;拒绝纯复制黏贴&#xff01;&#xff01;&#xff01; 有自己思想&#xff0c;拒绝纯复制黏贴&#xff01;&#xff01;&#xff01; 有自己思想&#xff0c;拒绝纯复制黏贴&#xff01;&#xff01;&#xff01; 一、问题背景二、处…

我用Python爬虫获取数据,分析双色球中奖概率,差点就中了

很多人喜欢买彩票,但是经常买彩票的人要么想着一夜暴富,要么想着改变命运,要么是娱乐娱乐,但是小编也要提醒大家一句,哪里能赚钱,哪里就有奸商,做事须谨慎。 前两天,在网上看到一个有意思的问题:彩票预测靠谱么?为什么还有那么多的人相信彩票预测? 暂且不说,彩票预…

学历、长相、家境普通的人,未来的发展方向是什么?00后的职业规划都已经整得明明白白

前言 “少壮不努力&#xff0c;老大徒伤悲” 相信你跟我有着类似的经历&#xff0c;年少时不知学习的重要性&#xff0c;没有好好念书&#xff0c;不由己的选择了一所不是理想的大学&#xff0c;然后选择了一个自己并不是很了解的专业。这里也不是说曾经的不好&#xff0c;而…