⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 insert.cpp

📁 学校的教学管理系统
💻 CPP
字号:
#include"head.h"
#include<iostream.h>
#include<stdlib.h>

extern void InitScore(Student*);
extern void InputDisplay(Student*);

void Insert(Student* &head)
{
    Student*pGuard;
	Student*pS;
	char choice;
	choice='y';

	while(choice=='y'||choice=='Y')
	{

		pS=new Student;
		InitScore(pS);
		pS->next=NULL;
		InputDisplay(pS);

status1:
		cout<<"请核对以上信息,输入内容完全无误吗?(y/n)";
		cin>>choice;

		if(choice=='n'||choice=='N')
		{
			cout<<"那么请重新输入吧."<<endl;
			system("pause");
			system("cls");
			InputDisplay(pS);
			goto status1;
		}
		else if(choice!='y'&&choice!='Y'&&choice!='n'&&choice!='N')
		{
			cout<<"您键入的内容有错,请重新选择."<<endl;
			goto status1;
		}

		
		if(head==NULL)
		{
			head=pS;
		}
		else
		{
			for(pGuard=head;pGuard->next!=NULL&&pGuard->next->Class<pS->Class;pGuard=pGuard->next)
			;
			if(pGuard==head&&pGuard->Class>pS->Class)
			{
				head=pS;
				pS->next=pGuard;
			}
			else if(pGuard==head&&pGuard->Class<pS->Class)
			{
				pS->next=head->next;
				head->next=pS;
			}
			else
			{
				pS->next=pGuard->next;
				pGuard->next=pS;
			}
		}
		system("cls");
status2:
		cout<<"还要输入下一个学生信息的吗?(y/n)";
		cin>>choice;

		if(choice!='y'&&choice!='Y'&&choice!='n'&&choice!='N')
		{
			cout<<"您键入的内容有错,请重新选择."<<endl;
			goto status2;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -