find.cpp

来自「程序功能: 1 管理员开设课程; 2 学生可以选择课程; 3 学生注册; 」· C++ 代码 · 共 72 行

CPP
72
字号
#include "cpp9.h"
#include<conio.h>
/********************
 * 查找学生信息函数
 ********************/

void  Student::find_record(Student *top)
{
	char choose[2],input[30];
	int cn = 0;	
	cout << "\t1. 通过学号寻找" << endl;
	cout << "\t2. 通过名字寻找"<<endl;
	cout<<"\t请选择1-2:"<< flush;
	gets(choose);
	while(1)
	{
		cn = atoi(choose);
		if (cn != 1 && cn != 2)
		{
			cout << "\t输入错误,重选1-2:" << flush;
			gets(choose);
		}
		else break;
	}
	switch(cn)
	{
	case 1:
		cout << "\t请输入学号:" << flush;
		break;
	case 2:
		cout << "\t请输入名字:" << flush;		
	}
	gets(input);
    printf("\t输入密码:");//用cout有缓冲问题 
	password pwc;
	pwc.set();

 

	Student *p;
	p = top;
	while(p!=NULL)
	{
		if (((cn == 1 && strcmp(input,p->no) == 0) 
			|| (cn == 2 && strcmp(input,p->name) == 0))&&(strcmp(pwc.Getp(),p->pw.Getp())==0)  )
		{
			cout << "\t找到的信息如下:" <<endl;
		   
	
			cout<<'\t'<<"学号:"<<p->no<<'\t'<<"姓名:"<<p->name<<'\t';
			 int j=0;
			    while(1)
				{
				    if(p->co[j].Getname()[0]=='0')break;
					cout<<p->co[j].Getname()<<":"<<p->co[j].Getscore();
				    j++;
				}
			
				cout<<"平均分:"<<p->ave<<endl;
		
			return;
		}
		else
		{
			p=p->next;
		}
	}
	cout << "\t密码错!" << endl;
	return ;
}

⌨️ 快捷键说明

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