#include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NULL 0 #define MaxSize 30 typedef struct athletestruct /*运动员*/ { char name[20]; int score; /*分数*/ int range; /**/ int item; /*项目*/ }ATH; typedef struct schoolstruct /*学校*/ { int count; /*编号*/ int serial; /**/ int menscore; /*男选手分数*/ int womenscore; /*女选手分数*/ int totalscore; /*总分*/ ATH athlete[MaxSize]; /**/ struct schoolstruct *next; }SCH; int nsc,msp,wsp; int ntsp; int i,j; int overgame; int serial,range; int n; SCH *head,*pfirst,*psecond; int *phead=NULL,*pafirst=NULL,*pasecond=NULL; void create(); void input () { char answer; head = (SCH *)malloc(sizeof(SCH)); /**/ head->next = NULL; pfirst = head; answer = 'y'; while ( answer == 'y' ) { Is_Game_DoMain: printf("\nGET Top 5 when odd\nGET Top 3 when even"); printf("\n输入运动项目序号 (x<=%d):",ntsp); scanf("%d",pafirst); overgame = *pafirst; if ( pafirst != phead ) { for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ ) { if ( overgame == *pasecond ) { printf("\n这个项目已经存在请选择其他的数字\n"); goto Is_Game_DoMain; } } } pafirst = pafirst + 1; if ( overgame > ntsp ) { printf("\n项目不存在"); printf("\n请重新输入"); goto Is_Game_DoMain; } switch ( overgame%2 ) { case 0: n = 3;break; case 1: n = 5;break; } for ( i = 1 ; i <= n ; i++ ) { Is_Serial_DoMain: printf("\n输入序号 of the NO.%d (0<x<=%d): ",i,nsc); scanf("%d",&serial); if ( serial > nsc ) { printf("\n超过学校数目,请重新输入"); goto Is_Serial_DoMain; } if ( head->next == NULL ) { create(); } psecond = head->next ; while ( psecond != NULL ) { if ( psecond->serial == serial ) { pfirst = psecond; pfirst->count = pfirst->count + 1; goto Store_Data; } else { psecond = psecond->next; } } create(); Store_Data: pfirst->athlete[pfirst->count].item = overgame; pfirst->athlete[pfirst->count].range = i; pfirst->serial = serial; printf("Input name:) : "); scanf("%s",pfirst->athlete[pfirst->count].name); } printf("\n继续输入运动项目(y&n)?"); answer = getchar(); printf("\n"); } } void calculate() /**/ { pfirst = head->next; while ( pfirst->next != NULL ) { for (i=1;i<=pfirst->count;i++) { if ( pfirst->athlete[i].item % 2 == 0 ) { switch (pfirst->athlete[i].range) { case 1:pfirst->athlete[i].score = 5;break; case 2:pfirst->athlete[i].score = 3;break; case 3:pfirst->athlete[i].score = 2;break; } } else { switch (pfirst->athlete[i].range) { case 1:pfirst->athlete[i].score = 7;break; case 2:pfirst->athlete[i].score = 5;break; case 3:pfirst->athlete[i].score = 3;break; case 4:pfirst->athlete[i].score = 2;break; case 5:pfirst->athlete[i].score = 1;break; } } if ( pfirst->athlete[i].item <=msp ) { pfirst->menscore = pfirst->menscore + pfirst->athlete[i].score; } else { pfirst->womenscore = pfirst->womenscore + pfirst->athlete[i].score; } } pfirst->totalscore = pfirst->menscore + pfirst->womenscore; pfirst = pfirst->next; } } void output() { pfirst = head->next; psecond = head->next; while ( pfirst->next != NULL ) { // clrscr(); printf("\n第%d号学校的结果成绩:",pfirst->serial); printf("\n\n项目的数目\t学校的名字\t分数"); for (i=1;i<=ntsp;i++) { for (j=1;j<=pfirst->count;j++) { if ( pfirst->athlete[j].item == i ) { printf("\n %d\t\t\t\t\t\t%s\n %d",i,pfirst->athlete[j].name,pfirst->athlete[j].score);break; } } } printf("\n\n\n\t\t\t\t\t\t按任意建 进入下一页"); getchar(); pfirst = pfirst->next; } // clrscr(); printf("\n运动会结果:\n\n学校编号\t男运动员成绩\t女运动员成绩\t总分"); pfirst = head->next; while ( pfirst->next != NULL ) { printf("\n %d\t\t %d\t\t %d\t\t %d",pfirst->serial,pfirst->menscore,pfirst->womenscore,pfirst->totalscore); pfirst = pfirst->next; } printf("\n\n\n\t\t\t\t\t\t\t按任意建结束"); getchar(); } void create() { pfirst = (struct schoolstruct *)malloc(sizeof(struct schoolstruct)); pfirst->next = head->next ; head->next = pfirst ; pfirst->count = 1; pfirst->menscore = 0; pfirst->womenscore = 0; pfirst->totalscore = 0; } void Save() {FILE *fp; if((fp = fopen("school.dat","wb"))==NULL) {printf("can't open school.dat\n"); fclose(fp); return; } fwrite(pfirst,sizeof(SCH),10,fp); fclose(fp); printf("文件已经成功保存\n"); } void main() { system("cls"); printf("\n\t\t\t 运动会分数统计\n"); printf("输入学校数目 (x>= 5):"); scanf("%d",&nsc); printf("输入男选手的项目(x<=20):"); scanf("%d",&msp); printf("输入女选手项目(<=20):"); scanf("%d",&wsp); ntsp = msp + wsp; phead = (int *)calloc(ntsp,sizeof(int)); pafirst = phead; pasecond = phead; input(); calculate(); output(); Save(); }
标签: 源代码
上传时间: 2016-12-28
上传用户:150501
// 学生管理.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "resource.h" #define MAX_LOADSTRING 100 // Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text // Foward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); struct person { char name[10]; int ID; int cj_yw; int cj_sx; struct person* next; struct person* pro; }per; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_MY, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MY); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; } // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // // COMMENTS: // // This function and its usage is only necessary if you want this code // to be compatible with Win32 systems prior to the 'RegisterClassEx' // function that was added to Windows 95. It is important to call this function // so that the application will get 'well formed' small icons associated // with it. // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_MY); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = (LPCSTR)IDC_MY; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex); } // // FUNCTION: InitInstance(HANDLE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } // // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; TCHAR szHello[MAX_LOADSTRING]; LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... RECT rt; GetClientRect(hWnd, &rt); DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } // Mesage handler for about box. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } break; } return FALSE; }
上传时间: 2016-12-29
上传用户:767483511
// 学生管理.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "resource.h" #define MAX_LOADSTRING 100 // Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text // Foward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); struct person { char name[10]; int ID; int cj_yw; int cj_sx; struct person* next; struct person* pro; }per; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_MY, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MY); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; } // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // // COMMENTS: // // This function and its usage is only necessary if you want this code // to be compatible with Win32 systems prior to the 'RegisterClassEx' // function that was added to Windows 95. It is important to call this function // so that the application will get 'well formed' small icons associated // with it. // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_MY); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = (LPCSTR)IDC_MY; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex); } // // FUNCTION: InitInstance(HANDLE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } // // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; TCHAR szHello[MAX_LOADSTRING]; LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... RECT rt; GetClientRect(hWnd, &rt); DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } // Mesage handler for about box. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } break; } return FALSE; }
标签: 学生 计算器
上传时间: 2016-12-29
上传用户:767483511
The AP2406 is a 1.5Mhz constant frequency, slope compensated current mode PWM step-down converter. The device integrates a main switch and a synchronous rectifier for high efficiency without an external Schottky diode. It is ideal for powering portable equipment that runs from a single cell lithium-Ion (Li+) battery. The AP2406 can supply 600mA of load current from a 2.5V to 5.5V input voltage. The output voltage can be regulated as low as 0.6V. The AP2406 can also run at 100% duty cycle for low dropout operation, extending battery life in portable system. Idle mode operation at light loads provides very low output ripple voltage for noise sensitive applications. The AP2406 is offered in a low profile (1mm) 5-pin, thin SOT package, and is available in an adjustable version and fixed output voltage of 1.2V, 1.5V and 1.8V
上传时间: 2017-02-23
上传用户:w124141
程序流程语句 1、 if 语句 2、 switch 语句 3、 while 语句 4、 for 语句 5、循环的嵌套 6、其他流程控制语句
上传时间: 2017-03-10
上传用户:qlxxx
#include<stdio.h> #include<windows.h> int xuanxiang; int studentcount; int banjihao[100]; int xueqihao[100][10]; char xm[100][100]; int xuehao[100][10]; int score[100][3]; int yuwen; int shuxue[000]; int yingyu[100]; int c[100]; int p; char x[1000][100]="",y[100][100]="";/*x学院 y专业 z班级*/ int z[100]; main() { void input(); void inputsc(); void alter(); void scbybannji(); printf("--------学生成绩管理-----\n"); printf("请按相应数字键来实现相应功能\n"); printf("1.录入学生信息 2.录入学生成绩 3.修改学生成绩\n"); printf("4.查询学生成绩 5.不及格科目及名单 6.按班级输出学生成绩单\n"); printf("请输入你要实现的功能所对应的数字:"); scanf("%d",&xuanxiang); system("cls"); getchar(); switch (xuanxiang) { case 1:input(); case 2:inputsc(); case 3:alter(); /*case 4:select score(); case 5:bujigekemujimingdan();*/ case 6:scbybanji; } } void input() { int i; printf("请输入你的学院名称:"); gets(x); printf("请输入你的专业名称:"); gets(y); printf("请输入你的班级号:"); scanf("%d",&z); printf("请输入你们一个班有几个人:"); scanf("%d",&p); system("cls"); for(i=0;i<p;i++) { printf("请输入第%d个学生的学号:",i+1); scanf("%d",xuehao[i]); getchar(); printf("请输入第%d个学生的姓名:",i+1); gets(xm[i]); system("cls"); } printf("您已经录入完毕您的班级所有学生的信息!\n"); printf("您的班级为%s%s%s\n",x,y,z); /*alter(p);*/ } void inputsc() { int i; for(i=0;i<p;i++) { printf("\n"); printf("--------------------------------------------------------------------------------\n\n"); printf("\t\t\t\t录入学生的成绩\n\n\n"); printf("--------------------------------------------------------------------------------\n\n"); printf("\t\t\t\t%s\n",xm[i]); printf("\n"); printf("\t\t\t\t数学:"); scanf("%d",&shuxue[i]); printf("\n"); getchar(); printf("\t\t\t\t英语:"); scanf("%d",&yingyu[i]); printf("\n"); getchar(); printf("\t\t\t\tc语言:"); scanf("%d",&c[i]); system("cls"); } } void alter() { int i;/*循环变量*/ int m[10000];/*要查询的学号*/ int b;/*修改后的成绩*/ char kemu[20]=""; printf("请输入你要修改的学生的学号"); scanf("%d",&m); for (i=0;i<p;i++) { if (m==xuehao[i]) { printf("%s的数学成绩为%d,英语成绩为%d,c语言成绩为%d,xm[i],shuxue[i],yingyu[i],c[i]"); printf("请输入你想修改的科目");} } gets(kemu); getchar(); if (kemu=="数学"); { scanf("%d",&b); shuxue[i]=b;} if (kemu=="英语"); { scanf("%d",&b); yingyu[i]=b;} if (kemu=="c语言"); { scanf("%d",&b); c[i]=b; } printf("%s的数学成绩为%d,英语成绩为%d,c语言成绩为%d,xm[i],shuxue[i],yingyu[i],c[i]"); } void scbybannji() { int i; char zyname[20]; int bjnumber; printf("请输入你的专业名称"); scanf("%s",&zyname); printf("请输入你的班级号"); scanf("%d",&bjnumber); for (i=0;i<p;i++) { if (zyname==y[i]); if (bjnumber==z[i]); printf("专业名称%s班级号%d数学成绩%d英语成绩%dc语言成绩%d,y[i],z[i],shuxue[i],yingyu[i],c[i]"); } }
标签: c语言
上传时间: 2018-06-08
上传用户:2369043090
The BTS5016SDA is a one channel high-side power switch in PG-TO252-5-11 package providing embedded protective functions. The power transistor is built by a N-channel vertical power MOSFET with charge pump. The design is based on Smart SIPMOS chip on chip technology. The BTS5016SDA has a current controlled input and offers a diagnostic feedback with load current sense and a defined fault signal in case of overload operation, overtemperature shutdown and/or short circuit shutdown.
上传时间: 2019-03-27
上传用户:guaixiaolong
Description The L9352B is an integrated quad low-side power switch to drive inductive loads like valves used in ABS systems. Two of the four channels are current regulators with current range from 0 mA to 2.25 A. All channels are protected against fail functions. They are monitored by a status output.
标签: L9352B
上传时间: 2019-03-27
上传用户:guaixiaolong
#include<stdio.h> #include<string.h> #include<stdlib.h> #define N 100 int iNumOfStu=0; struct score { float math; float english; float computer; }; struct student { int number; char name[20]; struct score sco; float average; }; struct student stu[N]; void print_menu(void);//输出菜单 void choosemenu(void);//菜单选择 void input_student1(int);//输入学生信息 void input_student2(void);//输入总函数 void input_student3(int &,int);//判断学号是否重复 void input_student4(int,int);//覆盖原信息 void sort_student3(student s[],int);//按照英语成绩排序 void sort_student4(student s[],int);//按照计算机成绩排序 void sort_student2(student s[],int);//按照数学成绩排序 void sort_student5(student s[],int);//按照平均成绩排序 float input_score2(int);//计算学生平均成绩 void print_student2(void);//显示表头 void print_student3(int);//显示学生信息 void print_student1(int);//显示全部学生资料 void sort_student1(void);//排序总函数 void menu(void);//菜单调度总函数 int search_student2(int);//按学号查询学生信息并输出 void search_student3(int);//按平均分最高查询并输出 void search_student1(void);//查询总函数 void delete_student2(int,int);//删除学生信息 void delete_student1(void);//删除总函数 void change_student2(int);//修改学生资料 void change_student1(void);//修改总函数 void input_score3(int);//统计成绩 void input_score1(void);//统计成绩总函数 void print_help(void);//输出帮助信息 void exit_student(void);//退出系统 void save_student(student *,int);//保存学生信息 void main() { menu(); } void save_student(student *s,int a)//保存学生信息 { FILE *fp; if((fp=fopen("d:\\学生信息.txt","wb"))==NULL) { printf("不能打开文件!\n"); } else { printf("保存信息到D盘\n"); fprintf(fp,"本班所有学生具体信息如下:\r\n"); fprintf(fp," 学号 姓名 数学成绩 英语成绩 计算机成绩 平均成绩\r\n"); for(int i=0;i<a;i++) { fprintf(fp,"%8d%12s%14.2f%14.2f%14.2f%14.2f\n",stu[i].number,stu[i].name,stu[i].sco.math,stu[i].sco.english,stu[i].sco.computer,stu[i].average); fprintf(fp,"\r\n"); } fclose(fp); printf("信息保存成功!\n"); } } void exit_student(void)//退出系统 { exit(1); } void print_help(void)//输出帮助信息 { printf("本系统所能容纳的最大学生数为%d人\n学生信息保存在D盘根目录下,保存文件为“学生信息.txt”。\n感谢使用!\n",N); } void input_score1(void)//统计成绩总函数 { int c; c=search_student2(iNumOfStu); printf("学号:%d\n",stu[c].number); printf("姓名:%s\n",stu[c].name); input_score3(c); printf("新成绩录入成功!\n"); stu[c].average=input_score2(c); } void input_score3(int a)//统计成绩 { printf("数学新成绩:"); scanf("%f",&stu[a].sco.math); printf("英语新成绩:"); scanf("%f",&stu[a].sco.english); printf("计算机新成绩:"); scanf("%f",&stu[a].sco.computer); } void change_student2(int a)//修改学生资料 { printf("学号:%d----修改为:",stu[a].number); scanf("%d",&stu[a].number); getchar(); printf("姓名:%s----修改为:",stu[a].name); gets(stu[a].name); printf("数学成绩:%.2f----修改为:",stu[a].sco.math); scanf("%f",&stu[a].sco.math); printf("英语成绩:%.2f----修改为:",stu[a].sco.english); scanf("%f",&stu[a].sco.english); printf("计算机成绩:%.2f----修改为:",stu[a].sco.computer); scanf("%f",&stu[a].sco.computer); } void change_student1(void)//修改总函数 { int c; c=search_student2(iNumOfStu); getchar(); printf("是否要修改此学生信息?(“y”代表是)"); char d; scanf("%c",&d); if(d=='y'||d=='Y') { change_student2(c); stu[c].average=input_score2(c); printf("信息修改成功!\n"); } } void delete_student1(void)//删除总函数 { int c; c=search_student2(iNumOfStu); getchar(); printf("是否删除此条记录?(“y”代表是)"); char d; scanf("%c",&d); if(d=='y'||d=='Y') { delete_student2(c,iNumOfStu); printf("记录已删除!\n"); } } void delete_student2(int a,int b)//删除学生信息 { for(int i=a;i<b-1;i++) { stu[i]=stu[i+1]; } --iNumOfStu; } void search_student1(void)//查询总函数 { printf("1、按学号查询\n2、按平均分最高查询\n请选择:"); int c; scanf("%d",&c); switch(c) { case 1: { search_student2(iNumOfStu); break; } case 2: { search_student3(iNumOfStu); break; } default: break; } } void menu(void)//菜单调度总函数 { print_menu(); choosemenu(); } void sort_student1(void)//排序总函数 { printf("1、按数学成绩排序\n2、按英语成绩排序\n3、按计算机成绩排序\n4、按平均成绩排序\n请选择:"); int c; scanf("%d",&c); switch(c) { case 1: { sort_student2(stu,iNumOfStu); break; } case 2: { sort_student3(stu,iNumOfStu); break; } case 3: { sort_student4(stu,iNumOfStu); break; } case 4: { sort_student5(stu,iNumOfStu); break; } default: break; } } void print_student1(int a)//显示全部学生资料 { printf("本班所有学生具体信息如下\n"); print_student2(); for(int i=0;i<a;i++) { print_student3(i); } } void print_student3(int a)//显示学生信息 { printf("%8d%12s%14.2f%14.2f%14.2f%14.2f\n",stu[a].number,stu[a].name,stu[a].sco.math,stu[a].sco.english,stu[a].sco.computer,stu[a].average); } void print_student2(void)//显示表头 { printf(" 学号 姓名 数学成绩 英语成绩 计算机成绩 平均成绩\n"); } void input_student4(int a,int b)//覆盖原信息 { stu[a]=stu[b-1]; --iNumOfStu; } void input_student3(int &a,int b)//判断学号是否重复 { if(a!=0) { int i=0; do { if(stu[a].number==stu[i].number) { printf("此学号代表的学生已录入\n1、覆盖原信息\n2、重新输入\n请选择:"); int c; scanf("%d",&c); switch(c) { case 1: { input_student4(i,iNumOfStu); a=iNumOfStu-1; printf("信息已替换!\n"); break; } case 2: { printf("请重新输入学生信息:\n"); input_student1(iNumOfStu-1); break; } default: break; } break; } ++i; } while(i<b-1); } } void print_menu(void)//输出菜单 { printf("======欢迎来到学生信息管理系统======\n"); printf(" 1、输入学生资料\n"); printf(" 2、删除学生资料\n"); printf(" 3、查询学生资料\n"); printf(" 4、修改学生资料\n"); printf(" 5、显示学生资料\n"); printf(" 6、统计学生成绩\n"); printf(" 7、排序学生成绩\n"); printf(" 8、保存学生资料\n"); printf(" 9、获取帮助信息\n"); printf(" 10、退出系统\n"); printf("====================================\n"); printf("请选择:"); } void input_student2(void)//输入总函数 { char end; printf("请输入学生信息(在最后一个学生信息录入完成后以“/”结束录入):\n"); for(int i=0;(end=getchar())!='/';i++) { input_student1(i); ++iNumOfStu; input_student3(i,iNumOfStu); } for(int j=0;j<iNumOfStu;j++) { stu[j].average=input_score2(j); } } void input_student1(int a)//输入学生信息 { printf("学号:"); scanf("%d",&stu[a].number); getchar(); printf("姓名:"); gets(stu[a].name); printf("数学成绩:"); scanf("%f",&stu[a].sco.math); printf("英语成绩:"); scanf("%f",&stu[a].sco.english); printf("计算机成绩:"); scanf("%f",&stu[a].sco.computer); } float input_score2(int a)//计算学生平均成绩 { return (stu[a].sco.math+stu[a].sco.english+stu[a].sco.computer)/3; } void search_student3(int a)//按平均分最高查询并输出 { int max=0; for(int i=0;i<a;i++) { if(stu[max].average<stu[i].average) { max=i; } } print_student2(); print_student3(max); } void sort_student2(student s[],int a)//按照数学成绩排序 { struct student temp; for(int i=0;i<a-1;i++) { int max=i; for(int j=i+1;j<a;j++) if(stu[j].sco.math>stu[max].sco.math) { max=j; } if(max!=i) { temp=stu[max]; stu[max]=stu[i]; stu[i]=temp; } } print_student2(); for(int k=0;k<a;k++) { print_student3(k); } } void sort_student3(student s[],int a)//按照英语成绩排序 { struct student temp; for(int i=0;i<a-1;i++) { int max=i; for(int j=i+1;j<a;j++) if(stu[j].sco.english>stu[max].sco.english) { max=j; } if(max!=i) { temp=stu[max]; stu[max]=stu[i]; stu[i]=temp; } } print_student2(); for(int k=0;k<a;k++) { print_student3(k); } } void sort_student4(student s[],int a)//按照计算机成绩排序 { struct student temp; for(int i=0;i<a-1;i++) { int max=i; for(int j=i+1;j<a;j++) if(stu[j].sco.computer>stu[max].sco.computer) { max=j; } if(max!=i) { temp=stu[max]; stu[max]=stu[i]; stu[i]=temp; } } print_student2(); for(int k=0;k<a;k++) { print_student3(k); } } void sort_student5(student s[],int a)//按照平均成绩排序 { struct student temp; for(int i=0;i<a-1;i++) { int max=i; for(int j=i+1;j<a;j++) if(stu[j].average>stu[max].average) { max=j; } if(max!=i) { temp=stu[max]; stu[max]=stu[i]; stu[i]=temp; } } print_student2(); for(int k=0;k<a;k++) { print_student3(k); } } int search_student2(int a)//按照学号查找学生并输出 { int num; int c; printf("请输入要查询的学号:"); scanf("%d",&num); for(int i=0;i<a;i++) { if(num==stu[i].number) { c=i; } } printf("此学生的信息是:\n"); print_student2(); print_student3(c); return c; } void choosemenu(void)//菜单选择 { int i; scanf("%d",&i); switch(i) { case 1: { input_student2(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 2: { delete_student1(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 3: { search_student1(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 4: { change_student1(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 5: { print_student1(iNumOfStu); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 6: { input_score1(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 7: { sort_student1(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 8: { save_student(stu,iNumOfStu); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 9: { print_help(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 10: { exit_student(); } default: break; } } 运行结果: 源文件下载地址: http://115.com/file/clnq138g#一个简单的学生成绩管理系统.rar (请将此地址复制到浏览器地址栏中访问下载页面)
标签: 成绩查询系统
上传时间: 2019-06-08
上传用户:啊的撒旦
#include<stdio.h> #include<string.h> #include<stdlib.h> #define N 100 int iNumOfStu=0; struct score { float math; float english; float computer; }; struct student { int number; char name[20]; struct score sco; float average; }; struct student stu[N]; void print_menu(void);//输出菜单 void choosemenu(void);//菜单选择 void input_student1(int);//输入学生信息 void input_student2(void);//输入总函数 void input_student3(int &,int);//判断学号是否重复 void input_student4(int,int);//覆盖原信息 void sort_student3(student s[],int);//按照英语成绩排序 void sort_student4(student s[],int);//按照计算机成绩排序 void sort_student2(student s[],int);//按照数学成绩排序 void sort_student5(student s[],int);//按照平均成绩排序 float input_score2(int);//计算学生平均成绩 void print_student2(void);//显示表头 void print_student3(int);//显示学生信息 void print_student1(int);//显示全部学生资料 void sort_student1(void);//排序总函数 void menu(void);//菜单调度总函数 int search_student2(int);//按学号查询学生信息并输出 void search_student3(int);//按平均分最高查询并输出 void search_student1(void);//查询总函数 void delete_student2(int,int);//删除学生信息 void delete_student1(void);//删除总函数 void change_student2(int);//修改学生资料 void change_student1(void);//修改总函数 void input_score3(int);//统计成绩 void input_score1(void);//统计成绩总函数 void print_help(void);//输出帮助信息 void exit_student(void);//退出系统 void save_student(student *,int);//保存学生信息 void main() { menu(); } void save_student(student *s,int a)//保存学生信息 { FILE *fp; if((fp=fopen("d:\\学生信息.txt","wb"))==NULL) { printf("不能打开文件!\n"); } else { printf("保存信息到D盘\n"); fprintf(fp,"本班所有学生具体信息如下:\r\n"); fprintf(fp," 学号 姓名 数学成绩 英语成绩 计算机成绩 平均成绩\r\n"); for(int i=0;i<a;i++) { fprintf(fp,"%8d%12s%14.2f%14.2f%14.2f%14.2f\n",stu[i].number,stu[i].name,stu[i].sco.math,stu[i].sco.english,stu[i].sco.computer,stu[i].average); fprintf(fp,"\r\n"); } fclose(fp); printf("信息保存成功!\n"); } } void exit_student(void)//退出系统 { exit(1); } void print_help(void)//输出帮助信息 { printf("本系统所能容纳的最大学生数为%d人\n学生信息保存在D盘根目录下,保存文件为“学生信息.txt”。\n感谢使用!\n",N); } void input_score1(void)//统计成绩总函数 { int c; c=search_student2(iNumOfStu); printf("学号:%d\n",stu[c].number); printf("姓名:%s\n",stu[c].name); input_score3(c); printf("新成绩录入成功!\n"); stu[c].average=input_score2(c); } void input_score3(int a)//统计成绩 { printf("数学新成绩:"); scanf("%f",&stu[a].sco.math); printf("英语新成绩:"); scanf("%f",&stu[a].sco.english); printf("计算机新成绩:"); scanf("%f",&stu[a].sco.computer); } void change_student2(int a)//修改学生资料 { printf("学号:%d----修改为:",stu[a].number); scanf("%d",&stu[a].number); getchar(); printf("姓名:%s----修改为:",stu[a].name); gets(stu[a].name); printf("数学成绩:%.2f----修改为:",stu[a].sco.math); scanf("%f",&stu[a].sco.math); printf("英语成绩:%.2f----修改为:",stu[a].sco.english); scanf("%f",&stu[a].sco.english); printf("计算机成绩:%.2f----修改为:",stu[a].sco.computer); scanf("%f",&stu[a].sco.computer); } void change_student1(void)//修改总函数 { int c; c=search_student2(iNumOfStu); getchar(); printf("是否要修改此学生信息?(“y”代表是)"); char d; scanf("%c",&d); if(d=='y'||d=='Y') { change_student2(c); stu[c].average=input_score2(c); printf("信息修改成功!\n"); } } void delete_student1(void)//删除总函数 { int c; c=search_student2(iNumOfStu); getchar(); printf("是否删除此条记录?(“y”代表是)"); char d; scanf("%c",&d); if(d=='y'||d=='Y') { delete_student2(c,iNumOfStu); printf("记录已删除!\n"); } } void delete_student2(int a,int b)//删除学生信息 { for(int i=a;i<b-1;i++) { stu[i]=stu[i+1]; } --iNumOfStu; } void search_student1(void)//查询总函数 { printf("1、按学号查询\n2、按平均分最高查询\n请选择:"); int c; scanf("%d",&c); switch(c) { case 1: { search_student2(iNumOfStu); break; } case 2: { search_student3(iNumOfStu); break; } default: break; } } void menu(void)//菜单调度总函数 { print_menu(); choosemenu(); } void sort_student1(void)//排序总函数 { printf("1、按数学成绩排序\n2、按英语成绩排序\n3、按计算机成绩排序\n4、按平均成绩排序\n请选择:"); int c; scanf("%d",&c); switch(c) { case 1: { sort_student2(stu,iNumOfStu); break; } case 2: { sort_student3(stu,iNumOfStu); break; } case 3: { sort_student4(stu,iNumOfStu); break; } case 4: { sort_student5(stu,iNumOfStu); break; } default: break; } } void print_student1(int a)//显示全部学生资料 { printf("本班所有学生具体信息如下\n"); print_student2(); for(int i=0;i<a;i++) { print_student3(i); } } void print_student3(int a)//显示学生信息 { printf("%8d%12s%14.2f%14.2f%14.2f%14.2f\n",stu[a].number,stu[a].name,stu[a].sco.math,stu[a].sco.english,stu[a].sco.computer,stu[a].average); } void print_student2(void)//显示表头 { printf(" 学号 姓名 数学成绩 英语成绩 计算机成绩 平均成绩\n"); } void input_student4(int a,int b)//覆盖原信息 { stu[a]=stu[b-1]; --iNumOfStu; } void input_student3(int &a,int b)//判断学号是否重复 { if(a!=0) { int i=0; do { if(stu[a].number==stu[i].number) { printf("此学号代表的学生已录入\n1、覆盖原信息\n2、重新输入\n请选择:"); int c; scanf("%d",&c); switch(c) { case 1: { input_student4(i,iNumOfStu); a=iNumOfStu-1; printf("信息已替换!\n"); break; } case 2: { printf("请重新输入学生信息:\n"); input_student1(iNumOfStu-1); break; } default: break; } break; } ++i; } while(i<b-1); } } void print_menu(void)//输出菜单 { printf("======欢迎来到学生信息管理系统======\n"); printf(" 1、输入学生资料\n"); printf(" 2、删除学生资料\n"); printf(" 3、查询学生资料\n"); printf(" 4、修改学生资料\n"); printf(" 5、显示学生资料\n"); printf(" 6、统计学生成绩\n"); printf(" 7、排序学生成绩\n"); printf(" 8、保存学生资料\n"); printf(" 9、获取帮助信息\n"); printf(" 10、退出系统\n"); printf("====================================\n"); printf("请选择:"); } void input_student2(void)//输入总函数 { char end; printf("请输入学生信息(在最后一个学生信息录入完成后以“/”结束录入):\n"); for(int i=0;(end=getchar())!='/';i++) { input_student1(i); ++iNumOfStu; input_student3(i,iNumOfStu); } for(int j=0;j<iNumOfStu;j++) { stu[j].average=input_score2(j); } } void input_student1(int a)//输入学生信息 { printf("学号:"); scanf("%d",&stu[a].number); getchar(); printf("姓名:"); gets(stu[a].name); printf("数学成绩:"); scanf("%f",&stu[a].sco.math); printf("英语成绩:"); scanf("%f",&stu[a].sco.english); printf("计算机成绩:"); scanf("%f",&stu[a].sco.computer); } float input_score2(int a)//计算学生平均成绩 { return (stu[a].sco.math+stu[a].sco.english+stu[a].sco.computer)/3; } void search_student3(int a)//按平均分最高查询并输出 { int max=0; for(int i=0;i<a;i++) { if(stu[max].average<stu[i].average) { max=i; } } print_student2(); print_student3(max); } void sort_student2(student s[],int a)//按照数学成绩排序 { struct student temp; for(int i=0;i<a-1;i++) { int max=i; for(int j=i+1;j<a;j++) if(stu[j].sco.math>stu[max].sco.math) { max=j; } if(max!=i) { temp=stu[max]; stu[max]=stu[i]; stu[i]=temp; } } print_student2(); for(int k=0;k<a;k++) { print_student3(k); } } void sort_student3(student s[],int a)//按照英语成绩排序 { struct student temp; for(int i=0;i<a-1;i++) { int max=i; for(int j=i+1;j<a;j++) if(stu[j].sco.english>stu[max].sco.english) { max=j; } if(max!=i) { temp=stu[max]; stu[max]=stu[i]; stu[i]=temp; } } print_student2(); for(int k=0;k<a;k++) { print_student3(k); } } void sort_student4(student s[],int a)//按照计算机成绩排序 { struct student temp; for(int i=0;i<a-1;i++) { int max=i; for(int j=i+1;j<a;j++) if(stu[j].sco.computer>stu[max].sco.computer) { max=j; } if(max!=i) { temp=stu[max]; stu[max]=stu[i]; stu[i]=temp; } } print_student2(); for(int k=0;k<a;k++) { print_student3(k); } } void sort_student5(student s[],int a)//按照平均成绩排序 { struct student temp; for(int i=0;i<a-1;i++) { int max=i; for(int j=i+1;j<a;j++) if(stu[j].average>stu[max].average) { max=j; } if(max!=i) { temp=stu[max]; stu[max]=stu[i]; stu[i]=temp; } } print_student2(); for(int k=0;k<a;k++) { print_student3(k); } } int search_student2(int a)//按照学号查找学生并输出 { int num; int c; printf("请输入要查询的学号:"); scanf("%d",&num); for(int i=0;i<a;i++) { if(num==stu[i].number) { c=i; } } printf("此学生的信息是:\n"); print_student2(); print_student3(c); return c; } void choosemenu(void)//菜单选择 { int i; scanf("%d",&i); switch(i) { case 1: { input_student2(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 2: { delete_student1(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 3: { search_student1(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 4: { change_student1(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 5: { print_student1(iNumOfStu); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 6: { input_score1(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 7: { sort_student1(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 8: { save_student(stu,iNumOfStu); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 9: { print_help(); printf("按回车键返回主菜单"); getchar(); getchar(); menu(); break; } case 10: { exit_student(); } default: break; } } 运行结果: 源文件下载地址: http://115.com/file/clnq138g#一个简单的学生成绩管理系统.rar (请将此地址复制到浏览器地址栏中访问下载页面) #include<stdio.h> #include<string.h> #include<stdlib.h> #define N 100 int iNumOfStu=0; struct score { float math; float english; float computer; }; struct student { int number; char name[20]; struct score sco; float average; }; struct student stu[N]; void print_menu(void);//输出菜单 void choosemenu(void);//菜单选择 void input_student1(int);//输入学生信息 void input_student2(void);//输入总函数 void input_student3(int &,int);//判断学号是否重复 void input_student4(int,int);//覆盖原信息 void sort_student3(student s[],int);//按照英语成绩排序 void sort_student4(student s[],int);//按照计算机成绩排序 void sort_student2(student s[],int);//按照数学成绩排序 void sort_student5(student s[],int);//按照平均成绩排序 float input_score2(int);//计算学生平均成绩 void print_student2(void);//显示表头 void print_student3(int);//显示学生信息 void print_student1(int);//显示全部学生资料 void sort_student1(void);//排序总函数 void menu(void);//菜单调度总函数 int search_student2(int);//按学号查询学生信息并输出 void search_student3(int);//按平均分最高查询并输出 void search_student1(void);//查询总函数 void delete_student2(int,int);//删除学生信息 void delete_student1(void);//删除总函数 void change_student2(int);//修改学生资料 void change_student1(void);//修改总函数 void input_score3(int);//统计成绩 void input_score1(void);//统计成绩总函数 void print_help(void);//输出帮助信息 void exit_student(void);//退出系统 void save_student(student *,int);//保存学生信息 void main() { menu(); } void save_student(student *s,int a)//保存学生信息 { FILE *fp; if((fp=fopen("d:\\学生信息.txt","wb"))==NULL) { printf("不能打开文件!\n"); } else { printf("保存信息到D盘\n"); fprintf(fp,"本班所有学生具体信息如下:\r\n"); fprintf(fp," 学号 姓名 数学成绩 英语成绩 计算机成绩 平均成绩\r\n"); for(int i=0;i<a;i++) { fprintf(fp,"%8d%12s%14.2f%14.2f%14.2f%14.2f\n",stu[i].number,stu[i].name,stu[i].sco.math,stu[i].sco.english,stu[i].sco.computer,stu[i].average); fprintf(fp,"\r\n"); } fclose(fp); printf("信息保存成功!\n"); } } void exit_student(void)//退出系统 { exit(1); } void print_help(void)//输出帮助信息 { printf("本系统所能容纳的最大学生数为%d人\n学生信息保存在D盘根目录下,保存文件为“学生信息.txt”。\n感谢使用!\n",N); } void input_score1(void)//统计成绩总函数 { int c; c=search_student2(iNumOfStu); printf("学号:%d\n",stu[c].number); printf("姓名:%s\n",stu[c].name); input_score3(c); printf("新成绩录入成功!
标签: c语言
上传时间: 2019-06-09
上传用户:啊的撒旦