데이터 구조 학생 정보 관리

1367 단어
// 000001.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "windows.h"
#include "iostream"

using namespace std;

struct stud
{
	char name[21];
	char phone[12];
	char add[51];
	char num[7];
	char birth[11];
}num[101],temp;

int j;

int main(int argc, char* argv[])
{
	char Comp_(char * ch);
	void Insert_();
	void Output_();
	void Sort_();

	Insert_();
	Sort_();
	Output_();

	return 0;
}

void Insert_()
{
	puts("How much do you want input:");
	scanf("%d",&j);
	for(int i=0;i<j;i++)
	{
		puts("Name:");
		scanf("%s",&num[i].name);
		puts("Phone:");
		scanf("%s",&num[i].phone);
		puts("Address:");
		scanf("%s",&num[i].add);
		puts("Zip:");
		scanf("%s",&num[i].num);
		puts("Brither:");
		scanf("%s",&num[i].birth);
		printf("Next:  %d
",i+2); } } void Output_() { for(int i=0;i<j;i++) printf("Name:%s Phone:%s Address:%s Zip:%s Brither:%s
", num[i].name,num[i].phone,num[i].add,num[i].num,num[i].birth); } void Sort_() { for(int i=0;i<j;i++) for(int k=0;k<j-i-1;k++) if(strcmp(num[k].name,num[k+1].name)>0) { temp=num[k]; num[k]=num[k+1]; num[k+1]=temp; } }

좋은 웹페이지 즐겨찾기