亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? student copy.cpp

?? 本程序是自己寫的一個關于學生管理系統,實現了查看所有學生信息,查找學生,刪除學生,輸入學生(按學號大小排列)功能.希望大家參考,指出需改進之處.
?? CPP
字號:
#include <iostream.h>
#include <fstream.h>
#include  <stdlib.h>
#include <string.h>
#include <stdio.h>


struct Stu
{
	long NO;
	char name[15];
	char sex;
	int Class;
};

class Student
{
public:
//	long NO;
//	char name[25];
//	char sex;
//	int Class;

	//void read_Init_student_data(Student *stu,int n);
	void read_keyboard_student_date();
	void find_from_student_no();
	void find_from_student_name();
	void delete_from_student_no();
	void delete_from_student_name();

};

//===========================================================================
    /*讀初始的學生個人信息:*/
//===========================================================================

/*
void read_Init_student_data(Stu *stu,int n)
{
	cout<<"Reading main's three student..."<<endl;
	ofstream outfile("f3.txt",ios::binary);
    if(!outfile)
	{
		cerr<<"outfile error!"<<endl;
		exit(1);
	}
	for(int i=0;i<4;i++)
		outfile.write((char*)&stu[i],sizeof(stu[i]));
    
    ifstream infile("f3.txt",ios::in);
    if(!infile)
	{
		cerr<<"infile error!"<<endl;
		exit(1);
	}
	for(int j=0;j<3;j++)
	{
		//infile.read((char*)&stu[j],sizeof(stu[j]));
		infile.read((char*)&stu[j],sizeof(stu[j]));
		cout<<stu[j].NO<<" "<<stu[j].name<<" "<<stu[j].sex<<" "<<stu[j].Class<<endl;
	}
	infile.close();
	outfile.close();
}
*/

//====================================================================
   /*讀入從鍵盤輸入的學生個人信息:*/
//====================================================================

void Student::read_keyboard_student_date()
{
	Stu stud;
	Stu studtemp;
	//統計結構體中學生的個數:
	//=====================================================
	int flags=0;
	ifstream ifile("f3.txt",ios::binary);
	ofstream ofile("temp2.txt",ios::binary);
	ifile.read((char*)(&studtemp),sizeof(studtemp));
	while(!ifile.eof())
	{
		ofile.write((char*)(&studtemp),sizeof(studtemp));
		ifile.read((char*)(&studtemp),sizeof(studtemp));
		flags+=1;
	}
	ifile.close();
	ofile.close();
	//=====================================================

	ifstream infile("f3.txt",ios::binary);
	ofstream temp_outfile("temp1.txt",ios::binary);


	    cout<<">>請輸入你要輸入的學生信息:"<<endl;
A:		cout<<"NO,name,sex,Class:";
		cin>>stud.NO>>stud.name>>stud.sex>>stud.Class;

//		Stu studtemp;
//		ifstream infile("f3.txt",ios::binary);
		int flags1=1;
		int flags2=0;
		int flags3=0;
		infile.read((char*)(&studtemp),sizeof(studtemp));
		while(!infile.eof())
		{
			if(stud.NO==studtemp.NO)
			{
				cout<<">>此學號已經存在,請重新輸入學生信息:"<<endl;
				goto A;
			}
//按學號的大小由小到大排序:
//hy1=========================================================================
		    else if(stud.NO > studtemp.NO)
			{
				temp_outfile.write((char*)(&studtemp),sizeof(studtemp));
				flags2+=1;
				flags3+=1;
			}
			else
				if(flags1==1)
				{
					temp_outfile.write((char*)(&stud),sizeof(stud));
					flags1=0;
					flags3+=1;
				}
			if(flags1==0)
				temp_outfile.write((char*)(&studtemp),sizeof(studtemp));
			if(flags2==flags)
				temp_outfile.write((char*)(&stud),sizeof(stud));
			infile.read((char*)(&studtemp),sizeof(studtemp));
//hy1========================================================================
		}
		if(flags3==0)
			temp_outfile.write((char*)(&stud),sizeof(stud));
		infile.close();
		temp_outfile.close();


/*		Stu studtemp1;

		infile.read((char*)(&studtemp1),sizeof(studtemp1));
        while(!infile.eof())
		{
			if(stud.NO < studtemp1.NO)
			{
				temp_outfile.write((char*)(&stud),sizeof(stud));
				temp_outfile.write((char*)(&studtemp1),sizeof(studtemp1));
			}
			else
			{
				temp_outfile.write((char*)(&studtemp1),sizeof(studtemp1));
			}

			infile.read((char*)(&studtemp1),sizeof(studtemp1));
		}
//		outfile.write((char*)(&stud),sizeof(stud));
    	temp_outfile.close();
		*/

 //       Stu studtemp2;
        ifstream temp_infile("temp1.txt",ios::binary);
		ofstream outfile("f3.txt",ios::binary);
        
		temp_infile.read((char*)(&studtemp),sizeof(studtemp));
		while(!temp_infile.eof())
		{
//			temp_infile.read((char*)(&studtemp2),sizeof(studtemp2));
			outfile.write((char*)(&studtemp),sizeof(studtemp));
			temp_infile.read((char*)(&studtemp),sizeof(studtemp));
		}
		
		temp_infile.close();
		outfile.close();
		cout<<">>輸入信息成功!"<<endl;


/*	ofstream outfile("f3.txt",ios::app | ios::binary);
	cout<<"Please input a student information:"<<endl;
    cout<<"NO,name,sex,Class:";
	cin>>stud.NO>>stud.name>>stud.sex>>stud.Class;
	outfile.write((char*)(&stud),sizeof(stud));
	outfile.close();*/
/*	char ch;
    cout<<">>是否要顯示所有學生信息(Y/N):";
	cin>>ch;
	if(ch=='Y' || ch=='y')
	{
		ifstream infile("f3.txt",ios::binary);
		if(!infile)
		{
			cerr<<"infile error!"<<endl;
			exit(1);
		}
		cout<<">>已有的所有學生的信息如下:"<<endl;
		infile.read((char*)(&stud),sizeof(stud));
		while(!infile.eof())
		{
			cout<<stud.NO<<" "<<stud.name<<" "<<stud.sex<<" "<<
				stud.Class<<endl;
			infile.read((char*)(&stud),sizeof(stud));
		}
		infile.close();
	}
	*/
}

//=================================================================
           /*按學號查找學生信息*/
//=================================================================

void Student::find_from_student_no()
{
	long num;
	cout<<">>輸入你要查找的學生號:";
	cin>>num;

	Stu studtemp;
    ifstream infile("f3.txt",ios::binary);
	infile.read((char*)(&studtemp),sizeof(studtemp));
	while(!infile.eof())
	{
		if(num==studtemp.NO)
		{
			cout<<">>你要找的學生信息是:";
			cout<<studtemp.NO<<" "<<studtemp.name<<" "<<studtemp.sex<<" "<<
				studtemp.Class<<endl;
			break;
		}
		infile.read((char*)(&studtemp),sizeof(studtemp));
	}
	if(num!=studtemp.NO)
		cout<<">>對不起,沒有你要找的學生信息!"<<endl;
	infile.close();
}

//=================================================================
           /*按姓名查找學生信息*/
//=================================================================

void Student::find_from_student_name()
{
//***********************************
	char nametemp[15];
	cout<<">>輸入要查找的學生名字:";
	cin>>nametemp;
//	cin.getline(nametemp,15);
//***********************************
//	cout<<nametemp;
	cout<<">>輸入你要查找的學生姓名:";
	int flag1=1;
	int flag2=0;
	Stu studtemp;
    ifstream infile("f3.txt",ios::binary);
	infile.read((char*)(&studtemp),sizeof(studtemp));
	while(!infile.eof())
	{
		if(strcmp(nametemp,studtemp.name)==0)
		{
			flag2++;
			if(flag1==1)
			{
				cout<<">>你要找的學生信息是:";
				flag1--;
			}
			cout<<studtemp.NO<<" "<<studtemp.name<<" "<<studtemp.sex<<" "<<
				studtemp.Class<<endl;
		}
		infile.read((char*)(&studtemp),sizeof(studtemp));
	}
	if(flag2==0)
		cout<<">>對不起,沒有你要找的學生信息!"<<endl;
	infile.close();
}

//=================================================================
           /*按學號刪除某學生信息*/
//=================================================================

void Student::delete_from_student_no()
{
	int flags=0;
	ifstream infile("f3.txt",ios::binary);
	ofstream outfile("temp.txt",ios::binary);
	long num;
	cout<<">>輸入你要刪除的學生號:";
	cin>>num;

	Stu studtemp;
	infile.read((char*)(&studtemp),sizeof(studtemp));
	while(!infile.eof())
	{
		if(num==studtemp.NO)
		{
			cout<<">>你要刪除的學生信息是:";
			cout<<studtemp.NO<<" "<<studtemp.name<<" "<<studtemp.sex<<" "<<
				studtemp.Class<<endl;
			flags=1;
		}
		else
			outfile.write((char*)(&studtemp),sizeof(studtemp));
		infile.read((char*)(&studtemp),sizeof(studtemp));
	}
//	if(num!=studtemp.NO)
//		cout<<">>沒有你要刪除的學生信息!"<<endl;
	infile.close();
    outfile.close();
	char ch3;
	if(flags==1)
	{
		cout<<">>你是否真要刪除此學生信息?(Y/N):";
		cin>>ch3;
	}
	
	if((flags==1) && (ch3 == 'Y' || ch3 == 'y'))
	{
		ifstream infile("temp.txt",ios::binary);
		ofstream outfile("f3.txt",ios::binary);
		infile.read((char*)(&studtemp),sizeof(studtemp));
		while(!infile.eof())
		{
			outfile.write((char*)(&studtemp),sizeof(studtemp));
			infile.read((char*)(&studtemp),sizeof(studtemp));
		}
		cout<<">>刪除成功!"<<endl;
		infile.close();
        outfile.close();
	}
	if(flags==0)
	{
		cout<<">>對不起,沒有你要刪除的學生信息!"<<endl;
	}
}

//=================================================================
           /*按姓名刪除某學生信息*/
//=================================================================

void Student::delete_from_student_name()
{
	int flags=0;
	int flag1=1,flag2=0;
	ifstream infile("f3.txt",ios::binary);
	ofstream outfile("temp.txt",ios::binary);
//******************************
	cout<<">>輸入你要刪除的學生姓名:";
    char find_name[15];
	cin>>find_name;
//	cin.getline(find_name,15,'\n');
//  char ch;
//	while((ch=getchar())!='\n')
//		cout<<ch;

//******************************

	Stu studtemp;
	infile.read((char*)(&studtemp),sizeof(studtemp));
	while(!infile.eof())
	{
		if(strcmp(find_name,studtemp.name)==0)
		{
			if(flag1==1)
			{
				cout<<">>你要刪除的學生信息是:";
				flag1--;
			}
			cout<<studtemp.NO<<" "<<studtemp.name<<" "<<studtemp.sex<<" "<<
				studtemp.Class<<endl;
			flags=1;
			flag2++;
		}
		else
			outfile.write((char*)(&studtemp),sizeof(studtemp));
		infile.read((char*)(&studtemp),sizeof(studtemp));
	}
//	if(num!=studtemp.NO)
//	cout<<">>沒有你要刪除的學生信息!"<<endl;
	infile.close();
    outfile.close();
	char ch3;
	if(flags==1)
	{
		cout<<">>你是否真要刪除這<<flag2<<個學生信息?(Y/N):";
		cin>>ch3;
	}
	
	if((flags==1) && (ch3 == 'Y' || ch3 == 'y'))
	{
		ifstream infile("temp.txt",ios::binary);
		ofstream outfile("f3.txt",ios::binary);
		infile.read((char*)(&studtemp),sizeof(studtemp));
		while(!infile.eof())
		{
			outfile.write((char*)(&studtemp),sizeof(studtemp));
			infile.read((char*)(&studtemp),sizeof(studtemp));
		}
		cout<<">>刪除成功!"<<endl;
		infile.close();
        outfile.close();
	}
	if(flags==0)
	{
		cout<<">>對不起,沒有你要刪除的學生信息!"<<endl;
	}
}

void main()
{
/*	Stu stu[3]=
	{
		{2007001,"huangyoun",'M',1},
		{2007002,"xuqian",'F',1},
		{2007003,"xiezhonghua",'M',2}
	};
*/
	int x;

A:	cout<<">>歡迎使用學生管理系統!請選擇你要的服務:"<<endl;
	cout<<"=>顯示所有學生信息請選擇 1 "<<endl;
	cout<<"=>輸入學生信息請選擇 2 "<<endl;
    cout<<"=>查找某學生信息請選擇 3 "<<endl;
    cout<<"=>刪除某學生信息請選擇 4 "<<endl;
	cout<<"=>退出此系統請選擇 5 "<<endl;
	cout<<">>你將選擇?(1/2/3/4/5):";
	cin>>x;

	Student ST;
//	read_Init_student_data(stu,3);
	if(x==2)
	{
		char ch_read;
B:		ST.read_keyboard_student_date();
		cout<<">>是否還要輸入?(Y/N):";
		cin>>ch_read;
		if(ch_read=='Y' || ch_read=='y')
			goto B;
		else
		{
			x=0;
			goto A;
		}
	}
	if(x==1)
	{
		Stu stud;
//		cout<<strlen(Stu);
		
		ifstream infile("f3.txt",ios::binary);
		if(!infile)
		{
			cerr<<"infile error!"<<endl;
			exit(1);
		}
		cout<<">>已有的所有學生的信息如下:"<<endl;
		cout<<"  學號   姓名   性別   班級"<<endl;
		infile.read((char*)(&stud),sizeof(stud));
		while(!infile.eof())
		{
			cout<<stud.NO<<" "<<stud.name<<" "<<stud.sex<<" "<<
				stud.Class<<endl;
			infile.read((char*)(&stud),sizeof(stud));
		}
		infile.close();
		x=0;
		goto A;
	}

	if(x==3)
	{
		char ch_find;
		char ch2;
		cout<<">>按學號(X)查找還按名字(M)查找?(X/M):";
		cin>>ch2;
	
		if(ch2=='X' || ch2=='x')
		{
C:			ST.find_from_student_no();
			cout<<">>是否還要查找?(Y/N):";
			cin>>ch_find;
			if(ch_find=='Y' || ch_find=='y')
				goto C;
			else
			{
				x=0;
				goto A;
			}
		}
		if(ch2=='M' || ch2=='m')
		{
D:			ST.find_from_student_name();
			cout<<">>是否還要查找?(Y/N):";
			cin>>ch_find;
			if(ch_find=='Y' || ch_find=='y')
				goto D;
			else
			{
				x=0;
				goto A;
			}
		}
	}

  //  ST.delete_from_student_no();
	if(x==4)
	{
		char ch_delete;
		char ch4;
		cout<<">>按學號(X)刪除還按名字(M)刪除?(X/M):";
		cin>>ch4;
		
		if(ch4=='X' || ch4=='x') 
		{
E:			ST.delete_from_student_no();
			cout<<">>是否還要刪除?(Y/N):";
			cin>>ch_delete;
			if(ch_delete=='Y' || ch_delete=='y')
				goto E;
			else
			{
				x=0;
				goto A;
			}
		}
		if(ch4=='M' || ch4=='m') 
		{
F:			ST.delete_from_student_name();
			cout<<">>是否還要刪除?(Y/N):";
			cin>>ch_delete;
			if(ch_delete=='Y' || ch_delete=='y')
				goto F;
			else
			{
				x=0;
				goto A;
			}
		}
	}

	if(x==5)
	{
		x=0;
		goto G;
	}



G:	cout<<">>謝謝使用!"<<endl;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美国产高清| 日韩欧美国产综合在线一区二区三区| 色婷婷国产精品综合在线观看| 欧美日韩一级大片网址| 久久久久久久久久久久久夜| 亚洲午夜久久久| a美女胸又www黄视频久久| 日韩午夜在线观看视频| 亚洲欧美欧美一区二区三区| 国产一区二区福利视频| 91精品国产欧美一区二区成人 | 精品成人私密视频| 亚洲主播在线播放| www.成人在线| 国产日韩欧美精品电影三级在线| 午夜影视日本亚洲欧洲精品| 91小视频在线观看| 国产日产欧美一区二区三区| 奇米777欧美一区二区| 日本韩国欧美一区| 亚洲天堂2014| 99久久夜色精品国产网站| 国产午夜精品福利| 久久99热这里只有精品| 欧美一区二区三区视频在线观看| 一区二区三区高清| 一本色道久久综合狠狠躁的推荐| 国产精品女同一区二区三区| 国产成人av资源| 国产午夜精品一区二区三区视频| 精品无人码麻豆乱码1区2区 | 国产精品久久三区| 国产成人久久精品77777最新版本| 日韩一区二区电影| 免费的国产精品| 日韩欧美国产系列| 久久99精品久久久| 久久久久久久久一| 国产凹凸在线观看一区二区| 久久青草国产手机看片福利盒子| 国产一区二区三区久久久| 久久综合九色综合欧美亚洲| 国产一区二区女| 欧美激情在线免费观看| 成人午夜免费电影| 亚洲欧美乱综合| 欧美午夜精品电影| 日本sm残虐另类| 久久综合色一综合色88| 大尺度一区二区| 成人免费在线视频观看| 在线中文字幕不卡| 日本成人在线看| 国产色91在线| 91官网在线免费观看| 日韩国产在线观看一区| 欧美精品一区二区三区久久久| 国产乱码精品一区二区三区五月婷| 欧美国产激情二区三区| 色美美综合视频| 首页欧美精品中文字幕| 久久这里只有精品首页| 99热精品国产| 美日韩一区二区| 国产精品青草久久| 欧美日韩国产在线观看| 国产精品99久| 午夜日韩在线观看| 国产清纯美女被跳蛋高潮一区二区久久w| 成人18精品视频| 婷婷久久综合九色综合伊人色| 久久综合久久99| 欧美中文字幕久久| 精品一区二区在线免费观看| 日韩一区在线看| 欧美不卡一二三| 99精品欧美一区二区蜜桃免费| 丝袜亚洲另类欧美综合| 国产精品视频免费| 91精品国产品国语在线不卡 | 久久福利视频一区二区| 国产精品久久一卡二卡| 日韩亚洲欧美在线| 色天使久久综合网天天| 国产一区欧美日韩| 婷婷国产在线综合| 中文字幕制服丝袜成人av | 国产丝袜欧美中文另类| 欧美性xxxxxxxx| 不卡电影一区二区三区| 激情图片小说一区| 香蕉成人啪国产精品视频综合网| 国产目拍亚洲精品99久久精品| 欧美日韩精品一区二区三区四区| 成人美女视频在线看| 激情深爱一区二区| 日本中文字幕一区| 一区二区三区av电影 | 99久久99久久综合| 国产精品一区2区| 蜜桃精品视频在线| 亚洲国产精品久久久久秋霞影院 | 欧美日韩高清一区二区不卡| 成人a级免费电影| 国产精品99久久久久久久女警| 免费在线观看精品| 日韩精品1区2区3区| 一个色妞综合视频在线观看| 成人欧美一区二区三区视频网页| 国产女人aaa级久久久级| 日韩欧美国产一二三区| 日韩一区二区精品葵司在线| 欧美精品日韩精品| 欧美日韩国产片| 欧美在线播放高清精品| 日本韩国欧美三级| 在线观看91精品国产入口| 一本色道久久综合亚洲aⅴ蜜桃| 99久久精品国产观看| 色综合天天性综合| 欧美影院一区二区三区| 欧美三级日韩在线| 7777精品久久久大香线蕉| 欧美电影影音先锋| 日韩手机在线导航| 久久婷婷色综合| 国产亚洲精品资源在线26u| 国产调教视频一区| 亚洲欧美综合色| 亚洲午夜久久久久久久久电影网| 午夜电影久久久| 久久精品免费观看| 国产成人亚洲综合a∨婷婷| 成人一区二区在线观看| 91欧美激情一区二区三区成人| 91久久国产最好的精华液| 欧美日本视频在线| 精品国产麻豆免费人成网站| 国产欧美综合在线观看第十页| 国产精品久久久久久亚洲伦| 一级精品视频在线观看宜春院| 五月天亚洲婷婷| 国产精品1区2区| 91高清在线观看| 精品国产一区二区三区不卡 | 久久综合视频网| 国产精品免费丝袜| 亚洲国产婷婷综合在线精品| 美女mm1313爽爽久久久蜜臀| 高清beeg欧美| 欧美精品电影在线播放| 精品国产一区久久| 一区二区三区中文在线观看| 奇米一区二区三区| a在线欧美一区| 日韩欧美国产wwwww| 最新日韩在线视频| 美女视频免费一区| 色综合一区二区| 2020国产精品| 天堂av在线一区| 99麻豆久久久国产精品免费| 欧美一区二区在线不卡| 国产精品久久久久久久久图文区 | 欧美日韩精品系列| 国产偷v国产偷v亚洲高清| 伊人婷婷欧美激情| 国产麻豆精品在线| 欧美三片在线视频观看| 国产日韩视频一区二区三区| 午夜精品久久久久| 91一区在线观看| 国产偷国产偷亚洲高清人白洁| 婷婷开心久久网| 色成人在线视频| 国产蜜臀97一区二区三区| 天天影视网天天综合色在线播放 | 欧美日韩国产另类不卡| 欧美国产精品劲爆| 久久99久久99| 日韩视频一区在线观看| 一区二区三区高清不卡| 不卡的av电影在线观看| 久久久蜜桃精品| 麻豆91在线看| 51精品国自产在线| 亚洲综合色网站| 91片黄在线观看| 亚洲欧洲性图库| 成人18精品视频| 中文字幕在线观看不卡视频| 国产精品18久久久| 久久久久国色av免费看影院| 国内外成人在线| 精品国产一区二区三区av性色| 美女视频黄免费的久久| 欧美一区二区在线播放| 日本不卡1234视频| 精品入口麻豆88视频| 国产综合色精品一区二区三区|