91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 25KB
    文件類型: .c
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-05-11
  • 語言: C/C++
  • 標簽:

資源簡介

一個大一學生寫的基于C語言的家譜管理系統(tǒng)

資源截圖

代碼片段和文件信息

#include?“stdio.h“
#include?“stdlib.h“
#include?“string.h“
#include?“math.h“
#include?“windows.h“

#define?MAXSIZE?200
#define?limit?10000000

typedef?struct?data
{
char?BornDay[8];
char?null[10];
char?Name[5];
char?null3[10];
char?Sex;//m代表男,f代表女//
char?Old[3];
char?null4[10];
char?Match[5];//設置若無配偶時輸入0//
char?null2[10];
char?DiedDay[8];//若未死亡輸入0//
char?null1[10];//字符數(shù)組前綴為Null的數(shù)組為存放野數(shù)據(jù)//
int?Age;//第幾代//
struct?data?*lchild*rchild*parent;
}BTree;

typedef?struct?midata
{
char?BornDay[8];
char?null[10];
char?Name[5];
char?null3[10];
char?Sex;//m代表男,f代表女//
char?Old[3];
char?null4[10];
char?Match[5];//設置若無配偶時輸入0//
char?null2[10];
char?DiedDay[8];//若未死亡輸入0//
char?null1[10];//字符數(shù)組前綴為Null的數(shù)組為存放野數(shù)據(jù)//
int?Age;//第幾代//
}mid;

void?MBNSubMenu(BTree?*bt);
void?SearchParent(BTree?*bt);
void?SearchChild(BTree?*bt);
void?saveNewData(BTree?*bt);
void?findDeep(BTree?*bt);
void?saveTheDelete(FILE?*fileBTree?*btmid?*mdp);

BTree?*Tstack[MAXSIZE];

char?name[5]old[3]sexBornDay[8]DiedDay[8]Match[5]choice1;
int?age=0flag=0i=0choicerear=1front=1count=1;//i為方便循環(huán)變量,用完全局變量記得初始化!//

//將文件中的數(shù)據(jù)導入樹結(jié)構(gòu)中//
BTree?*?inputTree(BTree?*root)//????核???????心????????代??????????碼????????//
{
FILE?*file;
BTree?*bt*fp;
mid?*mdp;
int?rear=1front=1mid1=1flag=0age=1;
file?=?fopen(“data““rb“)?;
if(file?!=?NULL)
{
while(!feof(file))//return?-1?while?to?the?file?end!//
{
mdp?=?(mid?*)malloc(sizeof(mid));
bt?=?(BTree?*)malloc(sizeof(BTree));
memset(bt0sizeof(BTree));//初始化結(jié)構(gòu)體,避免輸出亂碼//
if(fread(mdpsizeof(mid)1file)==1)
{
count++;
//進行數(shù)據(jù)拷貝//
strcpy(bt->Namemdp->Name);
bt->Name[strlen(bt->Name)]=‘\0‘;
strcpy(bt->Oldmdp->Old);

bt->Sex=mdp->Sex;

strcpy(bt->Matchmdp->Match);

strcpy(bt->BornDaymdp->BornDay);

strcpy(bt->DiedDaymdp->DiedDay?);
bt->Age=age;//年代信息與后變量相同//
flag=1;
}
bt->parent=NULL;
bt->lchild=NULL;
bt->rchild=NULL;
Tstack[rear]=bt;
rear++;
if(rear==2)
{
root=bt;
age++;mid1++;
}
else
{
if(Tstack[front]->lchild?==?NULL&&bt->Age!=0)//判斷該節(jié)點是否為有效節(jié)點//
{
bt->parent=Tstack[front];//指向父節(jié)點//
Tstack[front]->lchild=bt;
}
else?if(Tstack[front]->rchild?==?NULL&&bt->Age!=0)
{
bt->parent=Tstack[front];
Tstack[front]->rchild=bt;
}
else?if(Tstack[front]->rchild??&&?Tstack[front]->lchild)
{
front++;
if(front==mid1)
{
mid1=(int)(pow(2age)+0.5);
age++;
}//代計算//
bt->parent=Tstack[front];//指向父節(jié)點//
bt->Age=age;
if(strlen(bt->Name)!=0)?Tstack[front]->lchild=bt;
}
}
flag=0;//初始化檢測值,用來檢測是否拷貝了有效數(shù)據(jù)//
}
fclose(file);
printf(“\n讀取成功!\n“);
}
else
{
printf(“file?error!you?didn‘t?create?a?data?file?or?data?file?error!\n“);
getch();
exit(0);
}
return?root;
}

//創(chuàng)建一個全新的家庭樹//

void?CreateNewFam

評論

共有 條評論

相關資源