#include "string.h" #include "ctype.h" #include "stdio.h" search(char pd[]) {FILE *fp; int time=0,i=0,j=0,add[80],k=0,m; char *ch, str[900]; m=strlen(pd); if((fp=fopen("haha.txt","r"))==NULL) { printf("Cannot open this file\n"); exit(0); } for(;!feof(fp);i++) { str[i]=fgetc(fp); if(tolower(str[i])==tolower(pd[k])) {k++; if(k==m) if(!isalpha(i-m)&&!isalpha((str[i++]=fgetc(fp)))) { time++; add[j]=i-m+1; j++; k=0; } else k=0; } } if(time) { printf("The time is:%d\n",time); printf("The adders is:\n"); for(i=0;i
標(biāo)簽: 查詢學(xué)會(huì)少年宮
上傳時(shí)間: 2016-12-29
上傳用戶:767483511
#include "string.h" #include "ctype.h" #include "stdio.h" search(char pd[]) {FILE *fp; int time=0,i=0,j=0,add[80],k=0,m; char *ch, str[900]; m=strlen(pd); if((fp=fopen("haha.txt","r"))==NULL) { printf("Cannot open this file\n"); exit(0); } for(;!feof(fp);i++) { str[i]=fgetc(fp); if(tolower(str[i])==tolower(pd[k])) {k++; if(k==m) if(!isalpha(i-m)&&!isalpha((str[i++]=fgetc(fp)))) { time++; add[j]=i-m+1; j++; k=0; } else k=0; } } if(time) { printf("The time is:%d\n",time); printf("The adders is:\n"); for(i=0;i<j;i++) printf("%5d",add[i]); if(i%5==0) printf("\n"); getch(); fclose(fp); } else printf("Sorry!Cannot find the word(^_^)"); } main() { char pd[10],choose='y'; int flag=1; while(flag) {printf("In put the word you want to seqarch:"); scanf("%s",pd); search(strlwr(pd)); printf("\nWould you want to continue?(Y/N):"); getchar(); scanf("%c",&choose); if((tolower(choose))=='n') flag=0; else flag=1; } printf("Thanks for your using!Bye-bye!\n"); getch(); }
標(biāo)簽: 學(xué)生專用
上傳時(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; }
上傳時(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
#include <stdio.h> #include <stdlib.h> ///鏈?zhǔn)綏?nbsp; typedef struct node { int data; struct node *next; }Node,*Linklist; Linklist Createlist() { Linklist p; Linklist h; int data1; scanf("%d",&data1); if(data1 != 0) { h = (Node *)malloc(sizeof(Node)); h->data = data1; h->next = NULL; } else if(data1 == 0) return NULL; scanf("%d",&data1); while(data1 != 0) { p = (Node *)malloc(sizeof(Node)); p -> data = data1; p -> next = h; h = p; scanf("%d",&data1); } return h; } void Outputlist(Node *head) { Linklist p; p = head; while(p != NULL ) { printf("%d ",p->data); p = p->next; } printf("\n"); } void Freelist(Node *head) { Node *p; Node *q = NULL; p = head; while(p != NULL) { q = p; p = p->next; free(q); } } int main() { Node *head; head = Createlist(); Outputlist(head); Freelist(head); return 0; } 2.順序棧 [cpp] view plain copy #include <iostream> #include <stdio.h> #include <stdlib.h> ///順序棧 #define MaxSize 100 using namespace std; typedef
標(biāo)簽: 數(shù)據(jù)結(jié)構(gòu) 實(shí)驗(yàn)
上傳時(shí)間: 2018-05-09
上傳用戶:123456..
#include <iostream> #include <stdio.head> #include <stdlib.head> #include <string.head> #define ElemType int #define max 100 using namespace std; typedef struct node1 { ElemType data; struct node1 *next; }Node1,*LinkList;//鏈棧 typedef struct { ElemType *base; int top; }SqStack;//順序棧 typedef struct node2 { ElemType data; struct node2 *next; }Node2,*LinkQueue; typedef struct node22 { LinkQueue front; LinkQueue rear; }*LinkList;//鏈隊(duì)列 typedef struct { ElemType *base; int front,rear; }SqQueue;//順序隊(duì)列 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 //1.采用鏈?zhǔn)酱鎯?chǔ)實(shí)現(xiàn)棧的初始化、入棧、出棧操作。 LinkList CreateStack()//創(chuàng)建棧 { LinkList top; top=NULL; return top; } bool StackEmpty(LinkList s)//判斷棧是否為空,0代表空 { if(s==NULL) return 0; else return 1; } LinkList Pushead(LinkList s,int x)//入棧 { LinkList q,top=s; q=(LinkList)malloc(sizeof(Node1)); q->data=x; q->next=top; top=q; return top; } LinkList Pop(LinkList s,int &e)//出棧 { if(!StackEmpty(s)) { printf("棧為空。"); } else { e=s->data; LinkList p=s; s=s->next; free(p); } return s; } void DisplayStack(LinkList s)//遍歷輸出棧中元素 { if(!StackEmpty(s)) printf("棧為空。"); else { wheadile(s!=NULL) { cout<<s->data<<" "; s=s->next; } cout<<endl; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 //2.采用順序存儲(chǔ)實(shí)現(xiàn)棧的初始化、入棧、出棧操作。 int StackEmpty(int t)//判斷棧S是否為空 { SqStack.top=t; if (SqStack.top==0) return 0; else return 1; } int InitStack() { SqStack.top=0; return SqStack.top; } int pushead(int t,int e) { SqStack.top=t; SqStack.base[++SqStack.top]=e; return SqStack.top; } int pop(int t,int *e)//出棧 { SqStack.top=t; if(!StackEmpty(SqStack.top)) { printf("棧為空."); return SqStack.top; } *e=SqStack.base[s.top]; SqStack.top--; return SqStack.top; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 //3.采用鏈?zhǔn)酱鎯?chǔ)實(shí)現(xiàn)隊(duì)列的初始化、入隊(duì)、出隊(duì)操作。 LinkList InitQueue()//創(chuàng)建 { LinkList head; head->rear=(LinkQueue)malloc(sizeof(Node)); head->front=head->rear; head->front->next=NULL; return head; } void deleteEle(LinkList head,int &e)//出隊(duì) { LinkQueue p; p=head->front->next; e=p->data; head->front->next=p->next; if(head->rear==p) head->rear=head->front; free(p); } void EnQueue(LinkList head,int e)//入隊(duì) { LinkQueue p=(LinkQueue)malloc(sizeof(Node)); p->data=e; p->next=NULL; head->rear->next=p; head->rear=p; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 //4.采用順序存儲(chǔ)實(shí)現(xiàn)循環(huán)隊(duì)列的初始化、入隊(duì)、出隊(duì)操作。 bool InitQueue(SqQueue &head)//創(chuàng)建隊(duì)列 { head.data=(int *)malloc(sizeof(int)); head.front=head.rear=0; return 1; } bool EnQueue(SqQueue &head,int e)//入隊(duì) { if((head.rear+1)%MAXQSIZE==head.front) { printf("隊(duì)列已滿\n"); return 0; } head.data[head.rear]=e; head.rear=(head.rear+1)%MAXQSIZE; return 1; } int QueueLengthead(SqQueue &head)//返回隊(duì)列長(zhǎng)度 { return (head.rear-head.front+MAXQSIZE)%MAXQSIZE; } bool deleteEle(SqQueue &head,int &e)//出隊(duì) { if(head.front==head.rear) { cout<<"隊(duì)列為空!"<<endl; return 0; } e=head.data[head.front]; head.front=(head.front+1)%MAXQSIZE; return 1; } int gethead(SqQueue head)//得到隊(duì)列頭元素 { return head.data[head.front]; } int QueueEmpty(SqQueue head)//判斷隊(duì)列是否為空 { if (head.front==head.rear) return 1; else return 0; } void travelQueue(SqQueue head)//遍歷輸出 { wheadile(head.front!=head.rear) { printf("%d ",head.data[head.front]); head.front=(head.front+1)%MAXQSIZE; } cout<<endl; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 //5.在主函數(shù)中設(shè)計(jì)一個(gè)簡(jiǎn)單的菜單,分別測(cè)試上述算法。 int main() { LinkList top=CreateStack(); int x; wheadile(scanf("%d",&x)!=-1) { top=Pushead(top,x); } int e; wheadile(StackEmpty(top)) { top=Pop(top,e); printf("%d ",e); }//以上是鏈棧的測(cè)試 int top=InitStack(); int x; wheadile(cin>>x) top=pushead(top,x); int e; wheadile(StackEmpty(top)) { top=pop(top,&e); printf("%d ",e); }//以上是順序棧的測(cè)試 LinkList Q; Q=InitQueue(); int x; wheadile(scanf("%d",&x)!=-1) { EnQueue(Q,x); } int e; wheadile(Q) { deleteEle(Q,e); printf("%d ",e); }//以上是鏈隊(duì)列的測(cè)試 SqQueue Q1; InitQueue(Q1); int x; wheadile(scanf("%d",&x)!=-1) { EnQueue(Q1,x); } int e; wheadile(QueueEmpty(Q1)) { deleteEle(Q1,e); printf("%d ",e); } return 0; }
標(biāo)簽: 數(shù)據(jù)結(jié)構(gòu) 實(shí)驗(yàn)
上傳時(shí)間: 2018-05-09
上傳用戶:123456..
#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("不能打開文件!\n"); } else { printf("保存信息到D盤\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盤根目錄下,保存文件為“學(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("======歡迎來到學(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("按回車鍵返回主菜單"); 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; } } 運(yùn)行結(jié)果: 源文件下載地址: http://115.com/file/clnq138g#一個(gè)簡(jiǎn)單的學(xué)生成績(jī)管理系統(tǒng).rar (請(qǐng)將此地址復(fù)制到瀏覽器地址欄中訪問下載頁(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("不能打開文件!\n"); } else { printf("保存信息到D盤\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盤根目錄下,保存文件為“學(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("======歡迎來到學(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("按回車鍵返回主菜單"); 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; } } 運(yùn)行結(jié)果: 源文件下載地址: http://115.com/file/clnq138g#一個(gè)簡(jiǎn)單的學(xué)生成績(jī)管理系統(tǒng).rar (請(qǐng)將此地址復(fù)制到瀏覽器地址欄中訪問下載頁(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("不能打開文件!\n"); } else { printf("保存信息到D盤\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盤根目錄下,保存文件為“學(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
上傳用戶:啊的撒旦
PRODUCT DESCRIPTION The AD810 is a composite and HDTV compatible, current feedback, video operational amplifier, ideal for use in systems such as multimedia, digital tape recorders and video cameras. The 0.1 dB flatness specification at bandwidth of 30 MHz (G = +2) and the differential gain and phase of 0.02% and 0.04° (NTSC) make the AD810 ideal for any broadcast quality video system. All these specifications are under load conditions of 150 ? (one 75 ? back terminated cable). The AD810 is ideal for power sensitive applications such as video cameras, offering a low power supply current of 8.0 mA max. The disable feature reduces the power supply current to only 2.1 mA, while the amplifier is not in use, to conserve power. Furthermore the AD810 is specified over a power supply range of ±5 V to ±15 V.
上傳時(shí)間: 2020-04-19
上傳用戶:su1254
#include<stdio.h> #define TREEMAX 100 typedef struct BT { char data; BT *lchild; BT *rchild; }BT; BT *CreateTree(); void Preorder(BT *T); void Postorder(BT *T); void Inorder(BT *T); void Leafnum(BT *T); void Nodenum(BT *T); int TreeDepth(BT *T); int count=0; void main() { BT *T=NULL; char ch1,ch2,a; ch1='y'; while(ch1=='y'||ch1=='y') { printf("\n"); printf("\n\t\t 二叉樹子系統(tǒng)"); printf("\n\t\t*****************************************"); printf("\n\t\t 1---------建二叉樹 "); printf("\n\t\t 2---------先序遍歷 "); printf("\n\t\t 3---------中序遍歷 "); printf("\n\t\t 4---------后序遍歷 "); printf("\n\t\t 5---------求葉子數(shù) "); printf("\n\t\t 6---------求結(jié)點(diǎn)數(shù) "); printf("\n\t\t 7---------求樹深度 "); printf("\n\t\t 0---------返 回 "); printf("\n\t\t*****************************************"); printf("\n\t\t 請(qǐng)選擇菜單號(hào) (0--7)"); scanf("%c",&ch2); getchar(); printf("\n"); switch(ch2) { case'1': printf("\n\t\t請(qǐng)按先序序列輸入二叉樹的結(jié)點(diǎn):\n"); printf("\n\t\t說明:輸入結(jié)點(diǎn)(‘0’代表后繼結(jié)點(diǎn)為空)后按回車。\n"); printf("\n\t\t請(qǐng)輸入根結(jié)點(diǎn):"); T=CreateTree(); printf("\n\t\t二叉樹成功建立!\n");break; case'2': printf("\n\t\t該二叉樹的先序遍歷序列為:"); Preorder(T);break; case'3': printf("\n\t\t該二叉樹的中序遍歷序列為:"); Inorder(T);break; case'4': printf("\n\t\t該二叉樹的后序遍歷序列為:"); Postorder(T);break; case'5': count=0;Leafnum(T); printf("\n\t\t該二叉樹有%d個(gè)葉子。\n",count);break; case'6': count=0;Nodenum(T); printf("\n\t\t該二叉樹總共有%d個(gè)結(jié)點(diǎn)。\n",count);break; case'7': printf("\n\t\t該樹的深度為:%d",TreeDepth(T)); break; case'0': ch1='n';break; default: printf("\n\t\t***請(qǐng)注意:輸入有誤!***"); } if(ch2!='0') { printf("\n\n\t\t按【Enter】鍵繼續(xù),按任意鍵返回主菜單!\n"); a=getchar(); if(a!='\xA') { getchar(); ch1='n'; } } } } BT *CreateTree() { BT *t; char x; scanf("%c",&x); getchar(); if(x=='0') t=NULL; else { t=new BT; t->data=x; printf("\n\t\t請(qǐng)輸入%c結(jié)點(diǎn)的左子結(jié)點(diǎn):",t->data); t->lchild=CreateTree(); printf("\n\t\t請(qǐng)輸入%c結(jié)點(diǎn)的右子結(jié)點(diǎn):",t->data); t->rchild=CreateTree(); } return t; } void Preorder(BT *T) { if(T) { printf("%3c",T->data); Preorder(T->lchild); Preorder(T->rchild); } } void Inorder(BT *T) { if(T) { Inorder(T->lchild); printf("%3c",T->data); Inorder(T->rchild); } } void Postorder(BT *T) { if(T) { Postorder(T->lchild); Postorder(T->rchild); printf("%3c",T->data); } } void Leafnum(BT *T) { if(T) { if(T->lchild==NULL&&T->rchild==NULL) count++; Leafnum(T->lchild); Leafnum(T->rchild); } } void Nodenum(BT *T) { if(T) { count++; Nodenum(T->lchild); Nodenum(T->rchild); } } int TreeDepth(BT *T) { int ldep,rdep; if(T==NULL) return 0; else { ldep=TreeDepth(T->lchild); rdep=TreeDepth(T->rchild); if(ldep>rdep) return ldep+1; else return rdep+1; } }
上傳時(shí)間: 2020-06-11
上傳用戶:ccccy
蟲蟲下載站版權(quán)所有 京ICP備2021023401號(hào)-1