#include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NULL 0 #define MaxSize 30 typedef struct athletestruct /*運(yùn)動(dòng)員*/ { char name[20]; int score; /*分?jǐn)?shù)*/ int range; /**/ int item; /*項(xiàng)目*/ }ATH; typedef struct schoolstruct /*學(xué)校*/ { int count; /*編號(hào)*/ int serial; /**/ int menscore; /*男選手分?jǐn)?shù)*/ int womenscore; /*女選手分?jǐn)?shù)*/ 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輸入運(yùn)動(dòng)項(xiàng)目序號(hào) (x<=%d):",ntsp); scanf("%d",pafirst); overgame = *pafirst; if ( pafirst != phead ) { for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ ) { if ( overgame == *pasecond ) { printf("\n這個(gè)項(xiàng)目已經(jīng)存在請(qǐng)選擇其他的數(shù)字\n"); goto Is_Game_DoMain; } } } pafirst = pafirst + 1; if ( overgame > ntsp ) { printf("\n項(xiàng)目不存在"); printf("\n請(qǐng)重新輸入"); 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輸入序號(hào) of the NO.%d (0<x<=%d): ",i,nsc); scanf("%d",&serial); if ( serial > nsc ) { printf("\n超過(guò)學(xué)校數(shù)目,請(qǐng)重新輸入"); 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繼續(xù)輸入運(yùn)動(dòng)項(xiàng)目(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號(hào)學(xué)校的結(jié)果成績(jī):",pfirst->serial); printf("\n\n項(xiàng)目的數(shù)目\t學(xué)校的名字\t分?jǐn)?shù)"); 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按任意建 進(jìn)入下一頁(yè)"); getchar(); pfirst = pfirst->next; } // clrscr(); printf("\n運(yùn)動(dòng)會(huì)結(jié)果:\n\n學(xué)校編號(hào)\t男運(yùn)動(dòng)員成績(jī)\t女運(yùn)動(dòng)員成績(jī)\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按任意建結(jié)束"); 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("文件已經(jīng)成功保存\n"); } void main() { system("cls"); printf("\n\t\t\t 運(yùn)動(dòng)會(huì)分?jǐn)?shù)統(tǒng)計(jì)\n"); printf("輸入學(xué)校數(shù)目 (x>= 5):"); scanf("%d",&nsc); printf("輸入男選手的項(xiàng)目(x<=20):"); scanf("%d",&msp); printf("輸入女選手項(xiàng)目(<=20):"); scanf("%d",&wsp); ntsp = msp + wsp; phead = (int *)calloc(ntsp,sizeof(int)); pafirst = phead; pasecond = phead; input(); calculate(); output(); Save(); }
標(biāo)簽: 源代碼
上傳時(shí)間: 2016-12-28
上傳用戶:150501
// 學(xué)生管理.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; }
上傳時(shí)間: 2016-12-29
上傳用戶:767483511
// 學(xué)生管理.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; }
標(biāo)簽: 學(xué)生 計(jì)算器
上傳時(shí)間: 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
標(biāo)簽: 2406 AP 技術(shù)手冊(cè)
上傳時(shí)間: 2017-02-23
上傳用戶:w124141
程序流程語(yǔ)句 1、 if 語(yǔ)句 2、 switch 語(yǔ)句 3、 while 語(yǔ)句 4、 for 語(yǔ)句 5、循環(huán)的嵌套 6、其他流程控制語(yǔ)句
上傳時(shí)間: 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學(xué)院 y專(zhuān)業(yè) z班級(jí)*/ int z[100]; main() { void input(); void inputsc(); void alter(); void scbybannji(); printf("--------學(xué)生成績(jī)管理-----\n"); printf("請(qǐng)按相應(yīng)數(shù)字鍵來(lái)實(shí)現(xiàn)相應(yīng)功能\n"); printf("1.錄入學(xué)生信息 2.錄入學(xué)生成績(jī) 3.修改學(xué)生成績(jī)\n"); printf("4.查詢學(xué)生成績(jī) 5.不及格科目及名單 6.按班級(jí)輸出學(xué)生成績(jī)單\n"); printf("請(qǐng)輸入你要實(shí)現(xiàn)的功能所對(duì)應(yīng)的數(shù)字:"); 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("請(qǐng)輸入你的學(xué)院名稱:"); gets(x); printf("請(qǐng)輸入你的專(zhuān)業(yè)名稱:"); gets(y); printf("請(qǐng)輸入你的班級(jí)號(hào):"); scanf("%d",&z); printf("請(qǐng)輸入你們一個(gè)班有幾個(gè)人:"); scanf("%d",&p); system("cls"); for(i=0;i<p;i++) { printf("請(qǐng)輸入第%d個(gè)學(xué)生的學(xué)號(hào):",i+1); scanf("%d",xuehao[i]); getchar(); printf("請(qǐng)輸入第%d個(gè)學(xué)生的姓名:",i+1); gets(xm[i]); system("cls"); } printf("您已經(jīng)錄入完畢您的班級(jí)所有學(xué)生的信息!\n"); printf("您的班級(jí)為%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錄入學(xué)生的成績(jī)\n\n\n"); printf("--------------------------------------------------------------------------------\n\n"); printf("\t\t\t\t%s\n",xm[i]); printf("\n"); printf("\t\t\t\t數(shù)學(xué):"); scanf("%d",&shuxue[i]); printf("\n"); getchar(); printf("\t\t\t\t英語(yǔ):"); scanf("%d",&yingyu[i]); printf("\n"); getchar(); printf("\t\t\t\tc語(yǔ)言:"); scanf("%d",&c[i]); system("cls"); } } void alter() { int i;/*循環(huán)變量*/ int m[10000];/*要查詢的學(xué)號(hào)*/ int b;/*修改后的成績(jī)*/ char kemu[20]=""; printf("請(qǐng)輸入你要修改的學(xué)生的學(xué)號(hào)"); scanf("%d",&m); for (i=0;i<p;i++) { if (m==xuehao[i]) { printf("%s的數(shù)學(xué)成績(jī)?yōu)?d,英語(yǔ)成績(jī)?yōu)?d,c語(yǔ)言成績(jī)?yōu)?d,xm[i],shuxue[i],yingyu[i],c[i]"); printf("請(qǐng)輸入你想修改的科目");} } gets(kemu); getchar(); if (kemu=="數(shù)學(xué)"); { scanf("%d",&b); shuxue[i]=b;} if (kemu=="英語(yǔ)"); { scanf("%d",&b); yingyu[i]=b;} if (kemu=="c語(yǔ)言"); { scanf("%d",&b); c[i]=b; } printf("%s的數(shù)學(xué)成績(jī)?yōu)?d,英語(yǔ)成績(jī)?yōu)?d,c語(yǔ)言成績(jī)?yōu)?d,xm[i],shuxue[i],yingyu[i],c[i]"); } void scbybannji() { int i; char zyname[20]; int bjnumber; printf("請(qǐng)輸入你的專(zhuān)業(yè)名稱"); scanf("%s",&zyname); printf("請(qǐng)輸入你的班級(jí)號(hào)"); scanf("%d",&bjnumber); for (i=0;i<p;i++) { if (zyname==y[i]); if (bjnumber==z[i]); printf("專(zhuān)業(yè)名稱%s班級(jí)號(hào)%d數(shù)學(xué)成績(jī)%d英語(yǔ)成績(jī)%dc語(yǔ)言成績(jī)%d,y[i],z[i],shuxue[i],yingyu[i],c[i]"); } }
標(biāo)簽: c語(yǔ)言
上傳時(shí)間: 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.
上傳時(shí)間: 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.
標(biāo)簽: L9352B
上傳時(shí)間: 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);//輸入學(xué)生信息 void input_student2(void);//輸入總函數(shù) void input_student3(int &,int);//判斷學(xué)號(hào)是否重復(fù) void input_student4(int,int);//覆蓋原信息 void sort_student3(student s[],int);//按照英語(yǔ)成績(jī)排序 void sort_student4(student s[],int);//按照計(jì)算機(jī)成績(jī)排序 void sort_student2(student s[],int);//按照數(shù)學(xué)成績(jī)排序 void sort_student5(student s[],int);//按照平均成績(jī)排序 float input_score2(int);//計(jì)算學(xué)生平均成績(jī) void print_student2(void);//顯示表頭 void print_student3(int);//顯示學(xué)生信息 void print_student1(int);//顯示全部學(xué)生資料 void sort_student1(void);//排序總函數(shù) void menu(void);//菜單調(diào)度總函數(shù) int search_student2(int);//按學(xué)號(hào)查詢學(xué)生信息并輸出 void search_student3(int);//按平均分最高查詢并輸出 void search_student1(void);//查詢總函數(shù) void delete_student2(int,int);//刪除學(xué)生信息 void delete_student1(void);//刪除總函數(shù) void change_student2(int);//修改學(xué)生資料 void change_student1(void);//修改總函數(shù) void input_score3(int);//統(tǒng)計(jì)成績(jī) void input_score1(void);//統(tǒng)計(jì)成績(jī)總函數(shù) void print_help(void);//輸出幫助信息 void exit_student(void);//退出系統(tǒng) void save_student(student *,int);//保存學(xué)生信息 void main() { menu(); } void save_student(student *s,int a)//保存學(xué)生信息 { FILE *fp; if((fp=fopen("d:\\學(xué)生信息.txt","wb"))==NULL) { printf("不能打開(kāi)文件!\n"); } else { printf("保存信息到D盤(pán)\n"); fprintf(fp,"本班所有學(xué)生具體信息如下:\r\n"); fprintf(fp," 學(xué)號(hào) 姓名 數(shù)學(xué)成績(jī) 英語(yǔ)成績(jī) 計(jì)算機(jī)成績(jī) 平均成績(jī)\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)//退出系統(tǒng) { exit(1); } void print_help(void)//輸出幫助信息 { printf("本系統(tǒng)所能容納的最大學(xué)生數(shù)為%d人\n學(xué)生信息保存在D盤(pán)根目錄下,保存文件為“學(xué)生信息.txt”。\n感謝使用!\n",N); } void input_score1(void)//統(tǒng)計(jì)成績(jī)總函數(shù) { int c; c=search_student2(iNumOfStu); printf("學(xué)號(hào):%d\n",stu[c].number); printf("姓名:%s\n",stu[c].name); input_score3(c); printf("新成績(jī)錄入成功!\n"); stu[c].average=input_score2(c); } void input_score3(int a)//統(tǒng)計(jì)成績(jī) { printf("數(shù)學(xué)新成績(jī):"); scanf("%f",&stu[a].sco.math); printf("英語(yǔ)新成績(jī):"); scanf("%f",&stu[a].sco.english); printf("計(jì)算機(jī)新成績(jī):"); scanf("%f",&stu[a].sco.computer); } void change_student2(int a)//修改學(xué)生資料 { printf("學(xué)號(hào):%d----修改為:",stu[a].number); scanf("%d",&stu[a].number); getchar(); printf("姓名:%s----修改為:",stu[a].name); gets(stu[a].name); printf("數(shù)學(xué)成績(jī):%.2f----修改為:",stu[a].sco.math); scanf("%f",&stu[a].sco.math); printf("英語(yǔ)成績(jī):%.2f----修改為:",stu[a].sco.english); scanf("%f",&stu[a].sco.english); printf("計(jì)算機(jī)成績(jī):%.2f----修改為:",stu[a].sco.computer); scanf("%f",&stu[a].sco.computer); } void change_student1(void)//修改總函數(shù) { int c; c=search_student2(iNumOfStu); getchar(); printf("是否要修改此學(xué)生信息?(“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)//刪除總函數(shù) { 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)//刪除學(xué)生信息 { for(int i=a;i<b-1;i++) { stu[i]=stu[i+1]; } --iNumOfStu; } void search_student1(void)//查詢總函數(shù) { printf("1、按學(xué)號(hào)查詢\n2、按平均分最高查詢\n請(qǐng)選擇:"); int c; scanf("%d",&c); switch(c) { case 1: { search_student2(iNumOfStu); break; } case 2: { search_student3(iNumOfStu); break; } default: break; } } void menu(void)//菜單調(diào)度總函數(shù) { print_menu(); choosemenu(); } void sort_student1(void)//排序總函數(shù) { printf("1、按數(shù)學(xué)成績(jī)排序\n2、按英語(yǔ)成績(jī)排序\n3、按計(jì)算機(jī)成績(jī)排序\n4、按平均成績(jī)排序\n請(qǐng)選擇:"); 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)//顯示全部學(xué)生資料 { printf("本班所有學(xué)生具體信息如下\n"); print_student2(); for(int i=0;i<a;i++) { print_student3(i); } } void print_student3(int a)//顯示學(xué)生信息 { 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(" 學(xué)號(hào) 姓名 數(shù)學(xué)成績(jī) 英語(yǔ)成績(jī) 計(jì)算機(jī)成績(jī) 平均成績(jī)\n"); } void input_student4(int a,int b)//覆蓋原信息 { stu[a]=stu[b-1]; --iNumOfStu; } void input_student3(int &a,int b)//判斷學(xué)號(hào)是否重復(fù) { if(a!=0) { int i=0; do { if(stu[a].number==stu[i].number) { printf("此學(xué)號(hào)代表的學(xué)生已錄入\n1、覆蓋原信息\n2、重新輸入\n請(qǐng)選擇:"); int c; scanf("%d",&c); switch(c) { case 1: { input_student4(i,iNumOfStu); a=iNumOfStu-1; printf("信息已替換!\n"); break; } case 2: { printf("請(qǐng)重新輸入學(xué)生信息:\n"); input_student1(iNumOfStu-1); break; } default: break; } break; } ++i; } while(i<b-1); } } void print_menu(void)//輸出菜單 { printf("======歡迎來(lái)到學(xué)生信息管理系統(tǒng)======\n"); printf(" 1、輸入學(xué)生資料\n"); printf(" 2、刪除學(xué)生資料\n"); printf(" 3、查詢學(xué)生資料\n"); printf(" 4、修改學(xué)生資料\n"); printf(" 5、顯示學(xué)生資料\n"); printf(" 6、統(tǒng)計(jì)學(xué)生成績(jī)\n"); printf(" 7、排序?qū)W生成績(jī)\n"); printf(" 8、保存學(xué)生資料\n"); printf(" 9、獲取幫助信息\n"); printf(" 10、退出系統(tǒng)\n"); printf("====================================\n"); printf("請(qǐng)選擇:"); } void input_student2(void)//輸入總函數(shù) { char end; printf("請(qǐng)輸入學(xué)生信息(在最后一個(gè)學(xué)生信息錄入完成后以“/”結(jié)束錄入):\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)//輸入學(xué)生信息 { printf("學(xué)號(hào):"); scanf("%d",&stu[a].number); getchar(); printf("姓名:"); gets(stu[a].name); printf("數(shù)學(xué)成績(jī):"); scanf("%f",&stu[a].sco.math); printf("英語(yǔ)成績(jī):"); scanf("%f",&stu[a].sco.english); printf("計(jì)算機(jī)成績(jī):"); scanf("%f",&stu[a].sco.computer); } float input_score2(int a)//計(jì)算學(xué)生平均成績(jī) { 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)//按照數(shù)學(xué)成績(jī)排序 { 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)//按照英語(yǔ)成績(jī)排序 { 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)//按照計(jì)算機(jī)成績(jī)排序 { 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)//按照平均成績(jī)排序 { 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)//按照學(xué)號(hào)查找學(xué)生并輸出 { int num; int c; printf("請(qǐng)輸入要查詢的學(xué)號(hào):"); scanf("%d",&num); for(int i=0;i<a;i++) { if(num==stu[i].number) { c=i; } } printf("此學(xué)生的信息是:\n"); print_student2(); print_student3(c); return c; } void choosemenu(void)//菜單選擇 { int i; scanf("%d",&i); switch(i) { case 1: { input_student2(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 2: { delete_student1(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 3: { search_student1(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 4: { change_student1(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 5: { print_student1(iNumOfStu); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 6: { input_score1(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 7: { sort_student1(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 8: { save_student(stu,iNumOfStu); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 9: { print_help(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 10: { exit_student(); } default: break; } } 運(yùn)行結(jié)果: 源文件下載地址: http://115.com/file/clnq138g#一個(gè)簡(jiǎn)單的學(xué)生成績(jī)管理系統(tǒng).rar (請(qǐng)將此地址復(fù)制到瀏覽器地址欄中訪問(wèn)下載頁(yè)面)
標(biāo)簽: 成績(jī)查詢系統(tǒng)
上傳時(shí)間: 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);//輸入學(xué)生信息 void input_student2(void);//輸入總函數(shù) void input_student3(int &,int);//判斷學(xué)號(hào)是否重復(fù) void input_student4(int,int);//覆蓋原信息 void sort_student3(student s[],int);//按照英語(yǔ)成績(jī)排序 void sort_student4(student s[],int);//按照計(jì)算機(jī)成績(jī)排序 void sort_student2(student s[],int);//按照數(shù)學(xué)成績(jī)排序 void sort_student5(student s[],int);//按照平均成績(jī)排序 float input_score2(int);//計(jì)算學(xué)生平均成績(jī) void print_student2(void);//顯示表頭 void print_student3(int);//顯示學(xué)生信息 void print_student1(int);//顯示全部學(xué)生資料 void sort_student1(void);//排序總函數(shù) void menu(void);//菜單調(diào)度總函數(shù) int search_student2(int);//按學(xué)號(hào)查詢學(xué)生信息并輸出 void search_student3(int);//按平均分最高查詢并輸出 void search_student1(void);//查詢總函數(shù) void delete_student2(int,int);//刪除學(xué)生信息 void delete_student1(void);//刪除總函數(shù) void change_student2(int);//修改學(xué)生資料 void change_student1(void);//修改總函數(shù) void input_score3(int);//統(tǒng)計(jì)成績(jī) void input_score1(void);//統(tǒng)計(jì)成績(jī)總函數(shù) void print_help(void);//輸出幫助信息 void exit_student(void);//退出系統(tǒng) void save_student(student *,int);//保存學(xué)生信息 void main() { menu(); } void save_student(student *s,int a)//保存學(xué)生信息 { FILE *fp; if((fp=fopen("d:\\學(xué)生信息.txt","wb"))==NULL) { printf("不能打開(kāi)文件!\n"); } else { printf("保存信息到D盤(pán)\n"); fprintf(fp,"本班所有學(xué)生具體信息如下:\r\n"); fprintf(fp," 學(xué)號(hào) 姓名 數(shù)學(xué)成績(jī) 英語(yǔ)成績(jī) 計(jì)算機(jī)成績(jī) 平均成績(jī)\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)//退出系統(tǒng) { exit(1); } void print_help(void)//輸出幫助信息 { printf("本系統(tǒng)所能容納的最大學(xué)生數(shù)為%d人\n學(xué)生信息保存在D盤(pán)根目錄下,保存文件為“學(xué)生信息.txt”。\n感謝使用!\n",N); } void input_score1(void)//統(tǒng)計(jì)成績(jī)總函數(shù) { int c; c=search_student2(iNumOfStu); printf("學(xué)號(hào):%d\n",stu[c].number); printf("姓名:%s\n",stu[c].name); input_score3(c); printf("新成績(jī)錄入成功!\n"); stu[c].average=input_score2(c); } void input_score3(int a)//統(tǒng)計(jì)成績(jī) { printf("數(shù)學(xué)新成績(jī):"); scanf("%f",&stu[a].sco.math); printf("英語(yǔ)新成績(jī):"); scanf("%f",&stu[a].sco.english); printf("計(jì)算機(jī)新成績(jī):"); scanf("%f",&stu[a].sco.computer); } void change_student2(int a)//修改學(xué)生資料 { printf("學(xué)號(hào):%d----修改為:",stu[a].number); scanf("%d",&stu[a].number); getchar(); printf("姓名:%s----修改為:",stu[a].name); gets(stu[a].name); printf("數(shù)學(xué)成績(jī):%.2f----修改為:",stu[a].sco.math); scanf("%f",&stu[a].sco.math); printf("英語(yǔ)成績(jī):%.2f----修改為:",stu[a].sco.english); scanf("%f",&stu[a].sco.english); printf("計(jì)算機(jī)成績(jī):%.2f----修改為:",stu[a].sco.computer); scanf("%f",&stu[a].sco.computer); } void change_student1(void)//修改總函數(shù) { int c; c=search_student2(iNumOfStu); getchar(); printf("是否要修改此學(xué)生信息?(“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)//刪除總函數(shù) { 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)//刪除學(xué)生信息 { for(int i=a;i<b-1;i++) { stu[i]=stu[i+1]; } --iNumOfStu; } void search_student1(void)//查詢總函數(shù) { printf("1、按學(xué)號(hào)查詢\n2、按平均分最高查詢\n請(qǐng)選擇:"); int c; scanf("%d",&c); switch(c) { case 1: { search_student2(iNumOfStu); break; } case 2: { search_student3(iNumOfStu); break; } default: break; } } void menu(void)//菜單調(diào)度總函數(shù) { print_menu(); choosemenu(); } void sort_student1(void)//排序總函數(shù) { printf("1、按數(shù)學(xué)成績(jī)排序\n2、按英語(yǔ)成績(jī)排序\n3、按計(jì)算機(jī)成績(jī)排序\n4、按平均成績(jī)排序\n請(qǐng)選擇:"); 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)//顯示全部學(xué)生資料 { printf("本班所有學(xué)生具體信息如下\n"); print_student2(); for(int i=0;i<a;i++) { print_student3(i); } } void print_student3(int a)//顯示學(xué)生信息 { 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(" 學(xué)號(hào) 姓名 數(shù)學(xué)成績(jī) 英語(yǔ)成績(jī) 計(jì)算機(jī)成績(jī) 平均成績(jī)\n"); } void input_student4(int a,int b)//覆蓋原信息 { stu[a]=stu[b-1]; --iNumOfStu; } void input_student3(int &a,int b)//判斷學(xué)號(hào)是否重復(fù) { if(a!=0) { int i=0; do { if(stu[a].number==stu[i].number) { printf("此學(xué)號(hào)代表的學(xué)生已錄入\n1、覆蓋原信息\n2、重新輸入\n請(qǐng)選擇:"); int c; scanf("%d",&c); switch(c) { case 1: { input_student4(i,iNumOfStu); a=iNumOfStu-1; printf("信息已替換!\n"); break; } case 2: { printf("請(qǐng)重新輸入學(xué)生信息:\n"); input_student1(iNumOfStu-1); break; } default: break; } break; } ++i; } while(i<b-1); } } void print_menu(void)//輸出菜單 { printf("======歡迎來(lái)到學(xué)生信息管理系統(tǒng)======\n"); printf(" 1、輸入學(xué)生資料\n"); printf(" 2、刪除學(xué)生資料\n"); printf(" 3、查詢學(xué)生資料\n"); printf(" 4、修改學(xué)生資料\n"); printf(" 5、顯示學(xué)生資料\n"); printf(" 6、統(tǒng)計(jì)學(xué)生成績(jī)\n"); printf(" 7、排序?qū)W生成績(jī)\n"); printf(" 8、保存學(xué)生資料\n"); printf(" 9、獲取幫助信息\n"); printf(" 10、退出系統(tǒng)\n"); printf("====================================\n"); printf("請(qǐng)選擇:"); } void input_student2(void)//輸入總函數(shù) { char end; printf("請(qǐng)輸入學(xué)生信息(在最后一個(gè)學(xué)生信息錄入完成后以“/”結(jié)束錄入):\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)//輸入學(xué)生信息 { printf("學(xué)號(hào):"); scanf("%d",&stu[a].number); getchar(); printf("姓名:"); gets(stu[a].name); printf("數(shù)學(xué)成績(jī):"); scanf("%f",&stu[a].sco.math); printf("英語(yǔ)成績(jī):"); scanf("%f",&stu[a].sco.english); printf("計(jì)算機(jī)成績(jī):"); scanf("%f",&stu[a].sco.computer); } float input_score2(int a)//計(jì)算學(xué)生平均成績(jī) { 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)//按照數(shù)學(xué)成績(jī)排序 { 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)//按照英語(yǔ)成績(jī)排序 { 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)//按照計(jì)算機(jī)成績(jī)排序 { 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)//按照平均成績(jī)排序 { 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)//按照學(xué)號(hào)查找學(xué)生并輸出 { int num; int c; printf("請(qǐng)輸入要查詢的學(xué)號(hào):"); scanf("%d",&num); for(int i=0;i<a;i++) { if(num==stu[i].number) { c=i; } } printf("此學(xué)生的信息是:\n"); print_student2(); print_student3(c); return c; } void choosemenu(void)//菜單選擇 { int i; scanf("%d",&i); switch(i) { case 1: { input_student2(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 2: { delete_student1(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 3: { search_student1(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 4: { change_student1(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 5: { print_student1(iNumOfStu); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 6: { input_score1(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 7: { sort_student1(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 8: { save_student(stu,iNumOfStu); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 9: { print_help(); printf("按回車(chē)鍵返回主菜單"); getchar(); getchar(); menu(); break; } case 10: { exit_student(); } default: break; } } 運(yùn)行結(jié)果: 源文件下載地址: http://115.com/file/clnq138g#一個(gè)簡(jiǎn)單的學(xué)生成績(jī)管理系統(tǒng).rar (請(qǐng)將此地址復(fù)制到瀏覽器地址欄中訪問(wèn)下載頁(yè)面) #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);//輸入學(xué)生信息 void input_student2(void);//輸入總函數(shù) void input_student3(int &,int);//判斷學(xué)號(hào)是否重復(fù) void input_student4(int,int);//覆蓋原信息 void sort_student3(student s[],int);//按照英語(yǔ)成績(jī)排序 void sort_student4(student s[],int);//按照計(jì)算機(jī)成績(jī)排序 void sort_student2(student s[],int);//按照數(shù)學(xué)成績(jī)排序 void sort_student5(student s[],int);//按照平均成績(jī)排序 float input_score2(int);//計(jì)算學(xué)生平均成績(jī) void print_student2(void);//顯示表頭 void print_student3(int);//顯示學(xué)生信息 void print_student1(int);//顯示全部學(xué)生資料 void sort_student1(void);//排序總函數(shù) void menu(void);//菜單調(diào)度總函數(shù) int search_student2(int);//按學(xué)號(hào)查詢學(xué)生信息并輸出 void search_student3(int);//按平均分最高查詢并輸出 void search_student1(void);//查詢總函數(shù) void delete_student2(int,int);//刪除學(xué)生信息 void delete_student1(void);//刪除總函數(shù) void change_student2(int);//修改學(xué)生資料 void change_student1(void);//修改總函數(shù) void input_score3(int);//統(tǒng)計(jì)成績(jī) void input_score1(void);//統(tǒng)計(jì)成績(jī)總函數(shù) void print_help(void);//輸出幫助信息 void exit_student(void);//退出系統(tǒng) void save_student(student *,int);//保存學(xué)生信息 void main() { menu(); } void save_student(student *s,int a)//保存學(xué)生信息 { FILE *fp; if((fp=fopen("d:\\學(xué)生信息.txt","wb"))==NULL) { printf("不能打開(kāi)文件!\n"); } else { printf("保存信息到D盤(pán)\n"); fprintf(fp,"本班所有學(xué)生具體信息如下:\r\n"); fprintf(fp," 學(xué)號(hào) 姓名 數(shù)學(xué)成績(jī) 英語(yǔ)成績(jī) 計(jì)算機(jī)成績(jī) 平均成績(jī)\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)//退出系統(tǒng) { exit(1); } void print_help(void)//輸出幫助信息 { printf("本系統(tǒng)所能容納的最大學(xué)生數(shù)為%d人\n學(xué)生信息保存在D盤(pán)根目錄下,保存文件為“學(xué)生信息.txt”。\n感謝使用!\n",N); } void input_score1(void)//統(tǒng)計(jì)成績(jī)總函數(shù) { int c; c=search_student2(iNumOfStu); printf("學(xué)號(hào):%d\n",stu[c].number); printf("姓名:%s\n",stu[c].name); input_score3(c); printf("新成績(jī)錄入成功!
標(biāo)簽: c語(yǔ)言
上傳時(shí)間: 2019-06-09
上傳用戶:啊的撒旦
蟲(chóng)蟲(chóng)下載站版權(quán)所有 京ICP備2021023401號(hào)-1