asp.net C # student score management system code

Source: Internet
Author: User
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> #include <     conio.h> #define HEADER1 "--------------------------------students---------------------------------N" #define HEADER2 "   | School Number |   Class | name | language | Math | English | Total Score |      Average score |n "#define HEADER3" |----------|------|----------|------|------|------|------|----------|n "int saveflag=0;           Indicates whether the data needs to be filed struct student//represents the student's relevant information {char NUM[10];          Learning number char name[10];          Name Char grade[5];        class int Chinesemark;           Language score int Mathmark;        Math score int Englishmark;          English score int totalmark;     Total score Double Averagemark;

Average cent};
	typedef struct NODE//create linked list node {struct student data;
struct node *next;

}node,*link; 
	void Gotoxy (int x,int y)//Set cursor position {coord C; 
	C.x=x-1; 
	C.y=y-1; 
SetConsoleCursorPosition (GetStdHandle (Std_output_handle), c); } void Menu ()//main Menu displays {System ("CLS");         Clear screen System ("COLOR BD");
	Set font and background color gotoxy (15,4);
	printf ("Student Performance management Information System");
	Gotoxy (14,7);
	printf ("************************ menu ***************************");
	Gotoxy (14,9);
	printf ("* 1 Add student record 2 Delete student record 3 Find student record *");
	Gotoxy (14,11);
	printf ("* 4 revision of student Records 5 single score ranking 6 total grades *");
	Gotoxy (14,13);
	printf ("* 7 Information Preview 8 failed people statistics 9 highest sub-statistics *");
	Gotoxy (14,15);
	printf ("* 10 save Data 0 exits the system *");
	Gotoxy (14,17);
printf ("*******************************************************nn");
	} node* Locate (link L,char findness[],char nameornum[])//Find record location {node *r;
		if (strcmp (nameornum, "num") ==0)//Search by school number {r=l->next;
			while (R) {if (strcmp (r->data.num,findness) ==0) return R;                    r=r->next;
		If found, return node}} else if (strcmp (Nameornum, "name") ==0)//lookup by name {r=l->next;
			while (R) {if (strcmp (r->data.name,findness) ==0) return R;
		r=r->next;          } return 0;                   If not found, returns null} void Printfheader ()///Print Header {printf (header1);
	printf (Header2);
printf (HEADER3); } void Printdata (node *p)//print a record information {printf ("|%10s|%6s|%10s| %3d | %3d | %3d | %3d |%10.2f|n ", P->data.num,p->data.grade,p->data.name, p->data.chinesemark,p->data.mathmark,p-
>data.englishmark,p->data.totalmark,p->data.averagemark);
	} void Stringinput (char *t,unsigned int lens,char *notice)//input string {char s[20];             Do {printf (notice);
		Output hint information scanf ("%s", s);
	if (strlen (s) >lens-1) printf ("========> The length of the information you entered exceeds the range!n");
	}while (strlen (s) >lens);
strcpy (t,s);
    int Numinput (char *notice) {int num;           Do {printf (notice);
		Output hint information scanf ("%d", &num); if (num>100| |
	num<0) printf ("========> The score you entered is incorrect!, please re-enter n"); }while (num>100| |
	NUM&LT;0);
return num;
	} void Display (link l)//preview Print information {node *p,*r;
	int choice,select; Char grade[5];
	Char ch= ' y ';
	Char findness[20];
	int flag;
	p=l->next;
		if (p==null)//If no student record {printf ("n============> No student Record!n");
		GetChar ();
		printf ("Please press any key to return to main Menu n");
		System ("pause");
	Return
	printf ("nn");
	printf ("Student Information preview nn"); while (ch== ' y ') | |
		ch== ' y ') {printf (1 preview of Student information by Class 2 for individual information preview N);
		printf ("Please enter your choice: (1-2):");
		scanf ("%d", &choice);
		GetChar ();
		p=l->next;
		flag=0;
			if (choice==1) {printf ("=========> Please enter class (1-?):");
			scanf ("%s", grade);
				while (p)//detect if the entered class has a student record {if (strcmp (P->data.grade,grade) ==0) {flag++;
			} p=p->next;
			} if (flag==0) {printf ("========> does not have a record of the class of Students!n");
				else {p=l->next;
				Printfheader ();
						while (p) {if (strcmp (P->data.grade,grade) ==0) {printdata (P);
					printf (HEADER3);
				} p=p->next;
			} getchar (); printf ("n========> continue with the preview?" ( Y/n): ");
			scanf ("%c", &ch);
		GetChar ();
			else {printf ("==========>1 Preview 2 by name Preview n");
			printf ("Please enter your choice: (1-2):");
			scanf ("%d", &select);
			GetChar (); 
				if (select==1)//School Number Lookup {printf ("========> Please enter the school number:");
				scanf ("%s", findness);       R=locate (l,findness, "num");
				Record lookup Locating if (r==null)//If the student record does not exist {printf ("========> The student record does not exist!n");
					else {printfheader ();
					Printdata (R);
				printf (HEADER3);
				else//Name lookup {printf ("========> Please enter name:");
				scanf ("%s", findness);
				R=locate (l,findness, "name");
				if (r==null) {printf ("========> The student record does not exist!n");
					else {printfheader ();
					Printdata (R);
				printf (HEADER3);
			} getchar (); printf ("n========> continue with the preview?" (
			y/n): ");
		scanf ("%c", &ch); }} void Add (link L)//Add student record {node *p, *r,*s;
	Char ch1,ch2,flag=0,num[10];
	R=l;
	s=l->next;
	System ("CLS");
	while (r->next!=null)//Let R point to the end of the list to add the record {r=r->next;
	} ch2= ' Y '; while (ch2== ' y ') | |
			ch2== ' Y ') {while (1) {Stringinput (num,10, "Enter the student's number (enter 0 to return to the main menu):");
			flag=0;
			if (strcmp (num, "0") ==0)//If input 0, return the main menu {returns;
			} s=l->next;
					while (s)//detect whether the input's school number already exists {if (strcmp (s->data.num,num) ==0) {flag=1;
				Break
			} s=s->next;
				} if (flag==1)//input number already exists {GetChar (); printf ("This school number already exists, do you want to re-enter it?"
				y/n): ");
				scanf ("%c", &ch1); if (ch1== ' y ') | |
				ch1== ' y ') continue;
			else return;
			} else {break;      } p= (node *) malloc (sizeof (node));
		Input relevant information, establish student record node strcpy (p->data.num,num);
		Stringinput (p->data.grade,5, "Please enter the student's class (1-?):");
		Stringinput (p->data.name,10, "Please enter the student's name:");
		P->data.chinesemark=numinput ("Please enter the language score (0-100):");
		P->data.mathmark=numinput ("Please enter the Math score (0-100):"); P->datA.englishmark=numinput ("Please enter your English score (0-100):");
		p->data.totalmark=p->data.chinesemark+p->data.mathmark+p->data.englishmark;
		p->data.averagemark=p->data.totalmark/3.0;
		p->next=null;
		r->next=p;
		R=p;
		saveflag=1;
		GetChar (); printf ("n) do you want to continue adding student records?" (
		y/n): ");
	scanf ("%c", &AMP;CH2);
} return;
	} void Delete (link l)//delete student record {int select;
	Node *p,*r;
	Char findness[15];
	Char ch;
	p=l->next;
	Ch= ' Y ';
	System ("CLS");
        if (p==null)//If there is no student record {printf ("n) there is no student information record!" Press any key to return to the main menu ... n ");
        System ("pause");
	Return
	} printfheader ();
		while (p) {printdata (P);
		printf (HEADER3);
	p=p->next;
	printf ("Delete student record n"); while (ch== ' y ') | |
		ch== ' y ') {printf ("=============>1 deletes 2 by name delete n");
		printf ("Please enter your choice (1-2):");
		scanf ("%d", &select);
			if (select==1)//School Number Delete {stringinput (findness,10, "Please enter the student's number to be deleted:");
			R=locate (l,findness, "num");
				if (r) {p=l; while (p-&GT;NEXT!=R) p=p->next;            p->next=r->next;
				Merge nodes to delete student records} else {printf ("N Your input is incorrect, the student record does not exist!n"); printf ("=====> continue to delete?") (
				y/n): ");
				GetChar ();
				scanf ("%c", &ch);
			Continue
			Free (R); printf ("=====> continue to delete?") (
			y/n): ");
			GetChar ();
			scanf ("%c", &ch);
		saveflag=1;
			else if (select==2)//name deletion {stringinput (findness,10, "Please enter the name of the student to be deleted:");
			R=locate (l,findness, "name");
				if (r) {p=l;
				while (P-&GT;NEXT!=R) p=p->next;
			p->next=r->next;
				else {printf ("N Your input is incorrect, the student record does not exist!n"); printf ("=====> continue to delete?") (
				y/n): ");
				GetChar ();
				scanf ("%c", &ch);
			Continue
			Free (R); printf ("=====> continue to delete?") (
			y/n): ");
			GetChar ();
			scanf ("%c", &ch);
		saveflag=1;
			else {printf ("N Your input incorrectly!n"); printf ("=====> continue to delete?") (
			y/n): ");
			GetChar ();
		scanf ("%c", &ch);
	} void Search (link L)//Find student records {node *p,*r; int select;
	Char ch;
	Char findness[15];
	Ch= ' Y ';
	p=l->next;              System ("CLS");
		Clear screen if (p==null) {printf ("=========> no student record!) Please press any key to return to main menu ... n");
		GetChar ();
		System ("pause");
	Return while (ch== ' y ') | |
		ch== ' y ') {printf ("Find student records nn");
		printf ("1 by number find 2 by name find n");
		printf ("Please enter your choice (1-2):");
		scanf ("%d", &select);
		GetChar ();
			if (select==1)//by school number to find {stringinput (findness,10, "Please enter the student number you want to find:");
			R=locate (l,findness, "num");
			if (r==null)//If the student record does not exist {printf ("Your input is incorrect!"); The student record does not exist!n ");
				else {printfheader ();
				Printdata (R);
			printf (HEADER3); printf (======> continue with the lookup?
			y/n): ");
			GetChar ();
		scanf ("%c", &ch);
			else if (select==2)///by name find {stringinput (findness,10, "Please enter the name of the student you want to find:");
			R=locate (l,findness, "name");
			if (r==null)//If the student record does not exist {printf ("Your input is incorrect!"); The student record does not exist!n ");
				else {printfheader (); Printdata (R);
			printf (HEADER3); printf (======> continue with the lookup?
			y/n): ");
			GetChar ();
		scanf ("%c", &ch);
			else {printf ("Your input is incorrectly!n"); printf ("======> do you want to continue with the lookup?"
			y/n): ");
		scanf ("%c", &ch);
	}} void Modify (link L)//modify student record {node *p,*r;
	Char ch= ' y ';
	Char findness[15];
	p=l->next;
	System ("CLS");
		if (p==null) {printf ("n========> no Student records nn please press any key to return to main menu ...");
		GetChar ();
		GetChar ();
	Return
    printf ("Modify student record nn"); while (ch== ' y ') | |
        ch== ' y ') {stringinput (findness,10, "Please enter the student's school number to be modified:");            R=locate (l,findness, "num"); Locate the student record's node if (r==null) {printf (========) without the student record! Do you want to continue with the changes? (
			y/n): ");
			GetChar ();
			scanf ("%c", &ch);
		Continue
			else//Make changes, re-enter data {printf ("Please Re-enter Name:");
            scanf ("%s", r->data.name);
			printf ("Please re-enter class:");
			scanf ("%s", R->data.grade);
			printf ("Please re-enter the language score:");
		scanf ("%d", &r->data.chinesemark);	printf ("Please re-enter Math score:");
			scanf ("%d", &r->data.mathmark);
			printf ("Please re-enter your English score:");
			scanf ("%d", &r->data.englishmark);
			r->data.totalmark=r->data.chinesemark+r->data.mathmark+r->data.englishmark;
			r->data.averagemark=r->data.totalmark/3.0;
			saveflag=1; printf ("Does ========> continue to modify?" (
			y/n): ");
			GetChar ();
		scanf ("%c", &ch);
	}} void Sort1 (link L)//is ranked {node *p,*r,*s;
	Link l;
	int select;
	Char ch= ' y ';
	p=l->next;
	System ("CLS");
		if (p==null) {printf ("n========> does not have a student record!nn Press any key to return to the main menu ... n");
		GetChar ();
		GetChar ();
	Return
	printf ("Ranking nn for single subjects");
	printf ("1 by language score ranked 2 by mathematical results ranked 3 by English grade n"); while (ch== ' y ') | |
		ch== ' y ') {printf ("======> Please enter your choice (1-3):");
		scanf ("%d", &select);
		L= (node *) malloc (sizeof (node));                   l->next=null;
			The new Link Header node if (select==1)//insertion method is sorted, and the language score is ranked {p=l->next; while (p) {s= (node *) malloc (sizeof (node));
				Application of the node to store the student records taken out s->data=p->data;
				s->next=null;
				R=l;
				while (R->next&&r->next->data.chinesemark>s->data.chinesemark)//Find {r=r->next;
				if (r->next==null)//If all students ' grades are lower than those taken out {r->next=s;
					else {s->next=r->next;
				r->next=s;
			} p=p->next;
			} else if (select==2)//Math score Rank {p=l->next; 
				while (p) {s= (node *) malloc (sizeof (node));
				s->data=p->data;
				s->next=null;
				R=l;
				while (R->next&&r->next->data.mathmark>s->data.mathmark) {r=r->next;
				} if (r->next==null) {r->next=s;
					else {s->next=r->next;
				r->next=s;
			} p=p->next;
			} else//English scores rank {p=l->next;
				while (p) {s= (node *) malloc (sizeof (node));
				s->data=p->data; S->nExt=null;
				R=l;
				while (R->next&&r->next->data.englishmark>s->data.englishmark) {r=r->next;
				} if (r->next==null) {r->next=s;
					else {s->next=r->next;
				r->next=s;
			} p=p->next;
		}} l->next=l->next;
		p=l->next;
		Printfheader ();
			while (p) {printdata (P);
			printf (HEADER3);
		p=p->next; printf ("Does ========> continue?" (
		y/n): ");
		GetChar ();
		scanf ("%c", &ch);
	GetChar ();
} return;
	} void Sort2 (link L)//Total score rank {node *p,*r,*s;
    Link l;
	p=l->next;
	System ("CLS");
		if (p==null) {printf ("========> does not have a student record!n Press any key to return to the main menu ...");
		GetChar ();
		GetChar ();
	Return
	L= (node *) malloc (sizeof (node));
	l->next=null;
    p=l->next;      while (p) {s= (node *) malloc (sizeof (node));
		Application of the node to store the student records taken out s->data=p->data;
		s->next=null;
		R=l; while (R->next&&r->next->data.totalmark>s->data.totalmark)  Find {r=r->next;
		} if (r->next==null) {r->next=s;
			else {s->next=r->next;
		r->next=s;
	} p=p->next;
	} l->next=l->next;
	p=l->next;
	printf ("Ranking n" of the composite score);
	Printfheader ();
		while (p) {printdata (P);
		printf (HEADER3);
	p=p->next;
	printf ("n========> Press any key to return to main menu ...");
	GetChar ();
	
GetChar ();
	} void Topmark (link L)//highest score statistics {node *topchinese,*topmath,*topenglish,*toptotal;
	Node *p;
	int topchinesemark=0,topmathmark=0,topenglishmark=0,toptotalmark=0;
	p=l->next;
	System ("CLS");
		if (p==null) {printf ("n======> does not have a student record!n Press any key to return to the main menu ... n");
		GetChar ();
		GetChar ();
	Return
			} while (p)//find highest score {if (P->data.chinesemark>=topchinesemark) {topchinese=p;
		topchinesemark=p->data.chinesemark;
			} if (P->data.mathmark>=topmathmark) {topmath=p;
		topmathmark=p->data.mathmark; } if (P->data.englishmark>=topenglIshmark) {topenglish=p;
		topenglishmark=p->data.englishmark;
			} if (P->data.totalmark>=toptotalmark) {toptotal=p;
		toptotalmark=p->data.totalmark;
	} p=p->next;
	} gotoxy (24,8);
	printf ("Highest cent statistic nn"); printf ("Language highest score:%3d Name:%-10s:%-10sn", Topchinese->data.chinesemark, Topchinese->data.name,topc
	Hinese->data.num); printf ("Math Highest score:%3d Name:%-10s:%-10sn", Topmath->data.mathmark, Topmath->data.name,topmath->d
	Ata.num); printf ("English highest score:%3d Name:%-10s:%-10sn", Topenglish->data.englishmark, Topenglish->data.name,tope
	Nglish->data.num); printf ("Integrated highest score:%3d Name:%-10s:%-10sn", Toptotal->data.totalmark, toptotal->data.name,toptotal-&
	Gt;data.num);
	printf (' nn press any key to return to main menu ... ');
	GetChar ();
	GetChar ();
Return
	} void Count (link L)//Statistics The number of failing people and the total number of failing passes {int chinesecount=0;
	int mathcount=0;
	int englishcount=0; Inttotalcount=0;
	Node *p;
	p=l->next;
	System ("CLS");
		if (p==null)//If no student record {printf ("N No student Record!n");
		printf (Press any key to return to main menu ... n ");
		GetChar ();
		GetChar ();
	Return
		while (p) {if (P-&GT;DATA.CHINESEMARK&LT;60)//Statistical language failure number chinesecount++;
		if (P-&GT;DATA.ENGLISHMARK&LT;60)//Statistical English is not passing the number of englishcount++;
		if (P-&GT;DATA.MATHMARK&LT;60)//Statistical math failing number mathcount++; if (p->data.chinesemark<60| | p->data.englishmark<60| |
		P-&GT;DATA.MATHMARK&LT;60)//Statistical total failing number totalcount++;
	p=p->next;
	} gotoxy (24,8);
	printf ("Failed number of people statistics nn");
	printf ("The number of failed languages:%dnn", Chinesecount);
	printf ("Math failure Number:%DNN", Mathcount);
	printf ("English failing Number:%dnn", Englishcount);
	printf ("Total number of failed people:%dnn", totalcount);
	printf ("N Press any key to return to main menu ... n");
	GetChar ();
	GetChar ();
Return
	} void Save (link L)//Save data to disk file {*FP;
	Node *p; fp=fopen ("D:student.txt", "wt");
		Write-only open file if (fp==null) {printf ("N Open Data file failed!n");
		GetChar ();
	Return
	} p=l->next;
		while (p) {if (Fwrite (p,sizeof (node), 1,FP) ==1)//write data to file {p=p->next;
		} else {break;
	printf ("Save data successfully!n");
Fclose (FP);
	} void Wrong ()//error handling {printf ("============> error prompt: Your input is incorrect!n");
GetChar ();                 int main (void) {link l,p,r;               Linked list file *fp;             file pointer int select;                Indicates the choice char ch;        Input character l= (node*) malloc (sizeof (struct node));
		For the linked list Request Header node if (!l) {printf ("N-linked-node application failed!n");
	return 0;
	} l->next=null;
	R=l;         Fp=fopen ("D:student.txt", "at+");
		Open a text file as an append, readable and writable, and if the file does not exist, establish this file if (fp==null) {printf ("N Cannot Open Data file!n");
	Exit (0);
		while (!feof (FP)) {p= (node*) malloc (sizeof (node));
			if (!p) {printf ("Memory request failed!n");
		Exit (0);
			if (Fread p,sizeof (node), 1,FP) ==1)//Once read a student information record from a file {p->next=null; R->next=p;
		R=p;                               } fclose (FP);
    Closes the File menu ();                        while (1) {System ("CLS");
		Clear screen menu ();
		P=r;
		printf ("N Please select Action (0-10):");
		scanf ("%d", &select);
				if (select==0) {if (saveflag==1) {GetChar (); printf ("n=========> do you want to save the data?"
				y/n): ");
				scanf ("%c", &ch); if (ch== ' y ') | |
			ch== ' y ') Save (L);
			} getchar ();
		Break                       Switch (SELECT) {case 1:add (l);                    Add student record case 2:delete (l);                    Delete student record case 3:search (l);                    Find student record case 4:modify (l);                     Revise student record case 5:sort1 (l);                     According to the single section for students ranked Case 6:sort2 (l);     Students are ranked according to the total score case 7:system ("CLS");d Isplay (L);                     Preview the Student Information print case 8:count (l);                   Statistical case 9:topmark (L) for the number of people who fail in each section and the total number of passes; Save the data in case 10:save(l);
		Default:wrong (); GetChar (); break;	
} return 0; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.