编程实现一个手机通讯录或者短信管理功能,或者学生学籍管理的程序!

不要求完美!!!!符合初学者的水平即可!!要用数组结构体等数据类型!!!急急急!!!拜托拜托!!!
那个,请大家调试下再发上来吧……我调试总说有错误,基本上都是一个,可是我也不会改啊

我写过一个帐目系统希望对你有所帮助..
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<conio.h>
#include"Main.h"
#include"Interface.h"
#include"sort.h"
#ifndef _MAIN_H_
#define _MAIN_H_

#define MAX_ITEM 128
#define MAXITEMS 256

#define ITEM_EXIT 0
#define ITEM_ADD 1
#define ITEM_BROWSE 2
#define ITEM_FIND 3
#define ITEM_FIND_DEL 301
#define ITEM_FIND_CHANGE 302
#define ITEM_HELP 4

#define ITEM_NO 1
#define ITEM_DATE 2
#define ITEM_SORT 3
#define ITEM_PRO 4
#define ITEM_MONEY 5
#define ITEM_EXITS 0

#define SORT_SHOPPING 1
#define SORT_EAT 2
#define SORT_TOUR 3
#define SORT_FUN 4
#define SORT_DAILYOUT 5
#define SORT_OTHEROUT 6
#define SORT_GO_ON 7
#define SORT_EXIT 0

#define BROWSE_SORT 1
#define BROWSE_TIME 2
#define BROWSE_TIME_YEAR 1
#define BROWSE_TIME_MON 2
#define BROWSE_TIME_DAY 3
#define BROWSE_TIME_EXIT 0
#define BROWSE_ALL 3
#define BROWSE_EXIT 0

#define FIND_RECORD_TIME 1
#define FIND_RECORD_ITEMKEY 2
#define FIND_RECORD_MONEY 3
#define FIND_RECORD_EXIT 0

#define UPARROW 72
#define DOWNARROW 80

typedef struct {
unsigned int menu_no;
char menu_item[MAX_ITEM];
}ITEM_STRUCT_T;

typedef struct {
unsigned int sort_no;
char sort_item[MAX_ITEM];
}SORT_STRUCT_T;

typedef struct {
unsigned int item_no;
char item_list[MAX_ITEM];
}ITEM_LIST_STRUCT_T;

typedef struct {
unsigned int browse_no;
char browse_item[MAX_ITEM];
}BROWSE_STRUCT_T;

typedef struct {
unsigned int find_no;
char find_item[MAX_ITEM];
}FIND_STRUCT_T;

typedef struct {
unsigned int time_no;
char browse_item_time[MAX_ITEM];
}BROWSE_TIME_STRUCT_T;

typedef struct {
unsigned int record_no;
char find_record_item[MAX_ITEM];
}FIND_RECORD_STRUCT_T;

ITEM_STRUCT_T Item[] =
{
{ITEM_ADD, "添加支出"},
{ITEM_BROWSE, "浏览支出"},
{ITEM_FIND, "查找支出"},
{ITEM_HELP, "帮助选项"},
{ITEM_EXIT, "保存退出"},
};

SORT_STRUCT_T SORT_Item[] =
{
{SORT_SHOPPING, "购物"},
{SORT_EAT, "吃饭"},
{SORT_TOUR, "旅游"},
{SORT_FUN, "娱乐"},
{SORT_DAILYOUT, "日常开支"},
{SORT_OTHEROUT, "其他支出"},
{SORT_EXIT, "返回主菜单"},
};

BROWSE_STRUCT_T Browse_Item[] =
{
{BROWSE_SORT, "按类别浏览"},
{BROWSE_TIME, "按时间浏览"},
{BROWSE_ALL, "按全部浏览"},
{BROWSE_EXIT, "返回主菜单"}
};

BROWSE_TIME_STRUCT_T Browse_Item_Time[] =
{
{BROWSE_TIME_YEAR, "年"},
{BROWSE_TIME_MON, "月"},
{BROWSE_TIME_DAY, "日"},
{BROWSE_TIME_EXIT, "返回"},

};

ITEM_LIST_STRUCT_T List_Item[] =
{
{ITEM_NO, "编号"},
{ITEM_DATE, "日期"},
{ITEM_SORT, "类别"},
{ITEM_PRO, "项目"},
{ITEM_MONEY, "金额"},
{ITEM_EXITS, "退出"},
};

FIND_STRUCT_T Find_Item[] =
{
{ITEM_FIND_DEL, "删除"},
{ITEM_FIND_CHANGE, "修改"},
};

FIND_RECORD_STRUCT_T Find_Recrod_Item[] =
{
{FIND_RECORD_TIME, "按日期查询"},
{FIND_RECORD_ITEMKEY, "按项目关键字查询"},
{FIND_RECORD_MONEY, "按金额查询"},
{FIND_RECORD_EXIT, "返回"},
};

typedef struct
{
short Year;
short Month;
short Day;
}LIST_OUT_DATE;

typedef struct
{
int no;
LIST_OUT_DATE wdata;
short sort;
float money;
char items[MAXITEMS];
}LIST_OUT_TABLE;

typedef struct node
{
LIST_OUT_TABLE Listdata;
struct node * next;
}LINKLIST;

typedef struct node1
{
int orde;
LIST_OUT_TABLE Listdata;
struct node1 * next;
}LINKLIST1;

#define MAIN_ITEM_NUMBERS (sizeof(Item)/sizeof(Item[0]))
#define SORT_ITEM_NUMBERS (sizeof(SORT_Item)/sizeof(SORT_Item[0]))
#define BROWSE_ITEM_NUMBERS (sizeof(Browse_Item)/sizeof(Browse_Item[0]))
#define LIST_ITEM_NUMBERS (sizeof(List_Item)/sizeof(List_Item[0]))
#define BROWSE_ITEM_TIME_NUMBERS (sizeof(Browse_Item_Time)/sizeof(Browse_Item_Time[0]))
#define FIND_ITEM_NUMBERS (sizeof(Find_Item)/sizeof(Find_Item[0]))
#define FIND_ITEM_RECORD_NUMBERS (sizeof(Find_Recrod_Item)/sizeof(Find_Recrod_Item[0]))

int InitLInk();
int PrintItem();
void DisplayItem();
int SelectItem();
int SelectSortItem();
void ItemAdd();
void ItemBrowse();
int ItemBrowsSelect();
void DisplayChoiceItem(int item);
void DisplayAllItem();
int ItemList();
int ItemBrowsSelectTime();
void DisplayItemBrowsTime(int choice);
int ItemKeyFind(short key, int flag);
int RecordItem();
int ItemRecordFind();
int OnRecordTime(char *time);
int OnRecordMoney(float value);
int OndisplaychoiceInfo(int no);
void OnReOrder(void);
#endif
LINKLIST *Listhead = NULL;
LINKLIST1 *Tmphead = NULL;
int Global_i = 0;

int main()
{
int choice;
FILE *fp;
LINKLIST *p;
//Firstly, I must read content from file.

if (!InitLInk())
{
return 0;
}
while((choice = PrintItem()) != ITEM_EXIT)
{
system("cls");
switch(choice)
{
case ITEM_ADD:
ItemAdd();
break;
case ITEM_BROWSE:
ItemBrowse();
break;
case ITEM_FIND:
ItemRecordFind();
break;
case ITEM_HELP:
break;
default:
printf("你输入了一个错误的选项,请重试\n");
break;
}
}
p = Listhead->next;
fp = fopen("account.dat", "wb+");
if (fp == NULL)
{
printf("can not open the file!\n");
return 0;
}
while (p != NULL)
{
int ret = MyWriteFile(fp, (char *)&p->Listdata, sizeof(LIST_OUT_TABLE ));
//printf("%d\n", ret);
p = p->next;
}
system("cls");
printf("保存成功,按任意键关闭!\n");
getch();
fclose(fp);
return 0;
}

int PrintItem()
{
system("cls");
printf("\n ******************* Accountbook System *******************\n");
printf("%67s","By ZhaoChan 2008.7\n");
return SelectItem();
}

int SelectItem()
{
int i, choice;

for(i = 0; i < MAIN_ITEM_NUMBERS; i ++)
{
printf("%32d - %s\n", Item[i].menu_no, Item[i].menu_item);
}
printf("Input choice:");
scanf("%d", &choice);
return choice;
}

int InitLInk()
{
FILE *fp;
LIST_OUT_TABLE outtable;
LINKLIST *p, *s;
int ret;

p = Listhead = (LINKLIST *)malloc(sizeof(LINKLIST));
Tmphead = (LINKLIST1 *)malloc(sizeof(LINKLIST1));

Listhead->next = NULL;
Tmphead->next = NULL;

fp = fopen("account.dat", "rb+");
if (fp == NULL)
{
fp = fopen("account.dat", "wb +");
if (fp == NULL)
{
printf("Can't create account.dat\n");
return 0;
}
}
else
{
Global_i = GetFileLength(fp) / sizeof(LIST_OUT_TABLE);
rewind(fp);
while (!feof(fp))
{

ret = MyReadFile(fp, (char *)&outtable, sizeof(LIST_OUT_TABLE));
if (ret == 0)
break;
if (feof(fp))
break;
s = (LINKLIST *)malloc(sizeof(LINKLIST));
memcpy((void *)&s->Listdata, (void *)&outtable, sizeof(LIST_OUT_TABLE));
p->next = s;
p = s;
}
p->next = NULL;
}

fclose(fp);
return 1;
}

//添加操作
void ItemAdd()
{
int sort_choice;
float money;
LINKLIST *p, *s, *r;
struct tm when;
time_t now;
char c;

if (NULL == Listhead)
{
Listhead = (LINKLIST *)malloc(sizeof(LINKLIST));
}
r = Listhead;
p = Listhead->next;
printf("开始登记!\n");
while ((sort_choice = SelectSortItem()) != SORT_EXIT)
{
system("cls");
time(&now);
when = *localtime(&now);
while (p != NULL)
{
p = p->next;
r = r->next;
}

s = (LINKLIST *)malloc(sizeof(LINKLIST));
s->Listdata.no = Global_i;
s->Listdata.wdata.Day = when.tm_mday;
s->Listdata.wdata.Year = when.tm_year;
s->Listdata.wdata.Month = when.tm_mon;
s->Listdata.sort = sort_choice;
printf("输入开支项目:");
memset(s->Listdata.items, 0, MAX_ITEM);
scanf("%s", s->Listdata.items);
while (1)
{
printf("输入金额:");
scanf("%f", &money);
if (money > 0 && money < 65535)
break;
else
{
fflush(stdin);
system("cls");
printf("输入错误,是否重新添加?y/n\n");
c = getchar();
if (c != 'y' && c != 'Y')
return;
system("cls");
}
}
s->Listdata.money = money;
r->next = s;
r = s;
printf("添加成功,继续添加? y/n?-");
fflush(stdin);
c = getchar();
if (c != 'y' && c != 'Y')
break;
system("cls");
Global_i ++;
}
r->next = NULL;
system("cls");
}

int SelectSortItem()
{
int i, choice;

for (i = 0; i < SORT_ITEM_NUMBERS; i ++)
{
printf("%32d - %s\n", SORT_Item[i].sort_no, SORT_Item[i].sort_item);
}
printf("选择类别:");
scanf("%d", &choice);
return choice;
}

void ItemBrowse()
{
int browse_choice, choice;
while ((browse_choice = ItemBrowsSelect()) != BROWSE_EXIT)
{
system("cls");
switch(browse_choice)
{
case BROWSE_SORT:
choice = SelectSortItem();
system("cls");
DisplayChoiceItem(choice);
break;
case BROWSE_TIME:
choice = ItemBrowsSelectTime();
system("cls");
DisplayItemBrowsTime(choice);
break;
case BROWSE_ALL:
DisplayAllItem();
break;
default:
break;
}
printf("按任意键返回上级菜单!\n");
getch();
system("cls");
}
}

int ItemBrowsSelectTime()
{
int i, choice;

for (i = 0; i < BROWSE_ITEM_NUMBERS; i ++)
{
printf("%32d - %s\n", Browse_Item_Time[i].time_no, Browse_Item_Time[i].browse_item_time);
}
printf("choice:");
scanf("%d", &choice);
return choice;
}

void DisplayItemBrowsTime(int choice)
{
short key;
printf("输入%s(输入-1返回):", Browse_Item_Time[choice - 1].browse_item_time);
scanf("%d", &key);
if (key == -1)
return;
ItemKeyFind(key, choice);
}

int ItemBrowsSelect()
{
int i, choice;

for (i = 0; i < BROWSE_ITEM_NUMBERS; i ++)
{
printf("%32d - %s\n", Browse_Item[i].browse_no, Browse_Item[i].browse_item);
}
printf("choice:");
scanf("%d", &choice);
return choice;
}

void DisplayItem()
{
printf("%10s%12s%15s%15s%18s\n", "编号", "日期", "类别", "项目", "金额");
}

void DisplayChoiceItem(int item)
{
char times[128] = {0}, pbuf[128] = {0}, disbuf[1024 * 2] = {0};
char Sum[128]= {0};
float sum = 0;
LINKLIST *p;
p = Listhead->next;
memset(disbuf, 0, sizeof(disbuf));
memset(pbuf, 0, sizeof(pbuf));
while (p != NULL)
{
if (item == p->Listdata.sort)
{
sprintf(times, "%d-%d-%d", (p->Listdata.wdata.Year) - 100 + 2000, (p->Listdata.wdata.Month) + 1, p->Listdata.wdata.Day);
sprintf(pbuf, "%10d%12s%15s%15s%18.2f\n", p->Listdata.no, times, SORT_Item[p->Listdata.sort - 1].sort_item, p->Listdata.items, p->Listdata.money);
strcat(disbuf, pbuf);
sum += p->Listdata.money;
}
p = p->next;
}
sprintf(Sum, "%54sTotal:%10.2f\n", " ", sum);
strcat(disbuf, Sum);
DisplayItem();
printf("%s\n", disbuf);
}

void DisplayAllItem()
{
char times[128] = {0}, pbuf[128] = {0}, disbuf[1024 * 2] = {0}, Sum[128] = {0};
float sum = 0;
LINKLIST *p;
memset(disbuf, 0, sizeof(disbuf));
memset(pbuf, 0, sizeof(pbuf));
p = Listhead->next;
while (p != NULL)
{
sprintf(times, "%d-%d-%d", (p->Listdata.wdata.Year) - 100 + 2000, (p->Listdata.wdata.Month) + 1, p->Listdata.wdata.Day);
sprintf(pbuf, "%10d%12s%15s%15s%18.2f\n", p->Listdata.no, times, SORT_Item[p->Listdata.sort - 1].sort_item, p->Listdata.items, p->Listdata.money);
strcat(disbuf, pbuf);
sum += (p->Listdata.money);
p = p->next;
}
DisplayItem();
sprintf(Sum, "%54sTotal:%10.2f\n", " ", sum);
strcat(disbuf, Sum);
printf("%s\n", disbuf);
}

void ItemDeleted(int no)
{
LINKLIST *p, *r;
int i = 0;
p = Listhead->next;
r = Listhead;

while (p != NULL)
{
if (i == no)
break;
i ++;
r = r->next;
p = p->next;
}
r->next = p->next;
free(p);
}

void ItemChanged(int no)
{
LINKLIST *p;
int i = 0;
int sort, choice;
float money;
p = Listhead->next;
while (p != NULL)
{
if (i == no)
break;
i ++;
p = p->next;
}
while((choice = ItemList()) != ITEM_EXITS)
{
system("cls");
switch (choice)
{
case ITEM_SORT:
printf("Old 类别:%s\n", SORT_Item[p->Listdata.sort - 1].sort_item);
printf("修改类别:\n");
sort = SelectSortItem();
p->Listdata.sort = sort;
break;
case ITEM_PRO:
printf("Old 项目说明%s:\n", p->Listdata.items);
printf("修改项目说明:\n");
scanf("%s", p->Listdata.items);
break;
case ITEM_MONEY:
printf("Old 金额:%.2f\n", p->Listdata.money);
printf("修改金额:\n");
scanf("%f", &money);
p->Listdata.money = money;
break;
default:
printf("对不起,此项不许修改\n");
break;
}
system("cls");
}
}

int ItemList()
{
int i, choice;

for (i = 0; i < LIST_ITEM_NUMBERS; i ++)
{
printf("%32d - %s\n", List_Item[i].item_no, List_Item[i].item_list);
}
printf("选择:");
scanf("%d", &choice);
return choice;
}

int ItemKeyFind(short key, int flag)
{
LINKLIST *p;
char times[128] = {0}, pbuf[128] = {0}, disbuf[1024 * 2] = {0}, Sum[128] = {0};
float sum = 0;
short tmp = 0;
memset(disbuf, 0, sizeof(disbuf));
memset(pbuf, 0, sizeof(pbuf));
p = Listhead->next;
while (p != NULL)
{
switch(flag)
{
case BROWSE_TIME_YEAR:
tmp = p->Listdata.wdata.Year;
tmp = tmp + 2000 - 100;
break;
case BROWSE_TIME_MON:
tmp = p->Listdata.wdata.Month;
tmp = tmp + 1;
break;
case BROWSE_TIME_DAY:
tmp = p->Listdata.wdata.Day;
break;
}
if (tmp == key)
{
sprintf(times, "%d-%d-%d", (p->Listdata.wdata.Year) - 100 + 2000, (p->Listdata.wdata.Month) + 1, p->Listdata.wdata.Day);
sprintf(pbuf, "%10d%12s%15s%15s%18.2f\n", p->Listdata.no, times, SORT_Item[p->Listdata.sort - 1].sort_item, p->Listdata.items, p->Listdata.money);
strcat(disbuf, pbuf);
sum += p->Listdata.money;
}
p = p->next;

}
DisplayItem();
sprintf(Sum, "%54sTotal:%10.2f\n", " ", sum);
strcat(disbuf, Sum);
printf("%s\n", disbuf);
return 0;
}

int ItemRecordFind()
{
int choice;
char time[128]= {0}, c;
float money;
int ret;
int drvalue;
int offset, flag;
while ((choice = RecordItem()) != FIND_RECORD_EXIT)
{
switch(choice)
{
case FIND_RECORD_TIME:
system("cls");
printf("输入期:(如2008-7-8)");
scanf("%s", time);
system("cls");
ret = OnRecordTime(time);
flag = FIND_RECORD_TIME;
break;
case FIND_RECORD_ITEMKEY:
break;
case FIND_RECORD_MONEY:
system("cls");
while(1)
{
printf("输入金额:");
scanf("%f", &money);
if (money > 0 && money < 65535)
{
system("cls");
break;
}
else
{
fflush(stdin);
system("cls");
printf("输入错误,是否重新输入?y/n\n");
c = getchar();
if (c != 'y' && c != 'Y')
{
return 0;
}
system("cls");
}
}
ret = OnRecordMoney(money);
flag = FIND_RECORD_MONEY;
break;
default:
break;
}
printf("按w/s上下选择记录,d/r删除修改所选记录,q返回:\n");
fflush(stdin);
offset = 0;
while ((c = getch()) != 'q' )
{
if (c == 'd' || c == 'D')
{
system("cls");
printf("是否删除所选记录(y/n)\n");
fflush(stdin);
c = getchar();
if (c == 'y' || c == 'Y')
{
ItemDeleted(drvalue);
OnReOrder();
system("cls");
printf("删除成功!按任意键返回\n");
getch();

offset = 0;
}
system("cls");
if (flag == FIND_RECORD_TIME)
ret = OnRecordTime(time);
else if (flag == FIND_RECORD_MONEY)
ret = OnRecordMoney(money);
printf("按'w/s'上下选择记录,'d/r'删除修改所选记录,'q'返回:\n");
}
else if (c == 'r' || c == 'R')
{

system("cls");
printf("是否修改所选记录(y/n)\n");
fflush(stdin);
c = getchar();
if (c == 'y' || c == 'Y')
{
ItemChanged(drvalue);
system("cls");
printf("修改成功!按任意键返回\n");
getch();

offset = 0;
}
system("cls");
if (flag == FIND_RECORD_TIME)
ret = OnRecordTime(time);
else if (flag == FIND_RECORD_MONEY)
ret = OnRecordMoney(money);
printf("按'w/s'上下选择记录, 'd/r'删除修改所选记录,'q'退出:\n");
}
else if (c == 'w' || c == 'W')
{
if (offset == 0)
{
offset = offset + ret;
}
offset --;
}
else if (c == 's' || c == 'S')
{
offset ++;
if (offset == ret)
{
offset = 0;
}
}
drvalue = OndisplaychoiceInfo(offset);
}
system("cls");
}
return 0;
}

int RecordItem()
{
int i, choice;

for (i = 0; i < FIND_ITEM_RECORD_NUMBERS; i ++)
{
printf("%32d - %s\n", Find_Recrod_Item[i].record_no, Find_Recrod_Item[i].find_record_item);
}
printf("选择:");
scanf("%d", &choice);
return choice;
}

int OnRecordTime(char *time)
{
char times[128] = {0}, pbuf[128] = {0}, disbuf[1024 * 2] = {0}, Sum[128] = {0};
float sum = 0;
int cont = 0;
LINKLIST *p;
LINKLIST1 *tp, *ts;
memset(disbuf, 0, sizeof(disbuf));
memset(pbuf, 0, sizeof(pbuf));
p = Listhead->next;
tp = Tmphead;

while (p != NULL)
{
sprintf(times, "%d-%d-%d", (p->Listdata.wdata.Year) - 100 + 2000, (p->Listdata.wdata.Month) + 1, p->Listdata.wdata.Day);
if (!strcmp(time, times))
{
ts = (LINKLIST1 *)malloc(sizeof(LINKLIST1));
ts->orde = cont;
memcpy(&ts->Listdata, &p->Listdata, sizeof(LIST_OUT_TABLE));
tp->next = ts;
tp = ts;
sprintf(pbuf, "%10d%12s%15s%15s%18.2f\n", p->Listdata.no, times, SORT_Item[p->Listdata.sort - 1].sort_item, p->Listdata.items, p->Listdata.money);
strcat(disbuf, pbuf);
sum += p->Listdata.money;
cont ++;
}
memset(times, 0, sizeof(times));
p = p->next;
}
tp->next = NULL;
DisplayItem();
sprintf(Sum, "%54sTotal:%10.2f\n", " ", sum);
strcat(disbuf, Sum);
printf("%s\n", disbuf);
return cont;

}

int OnRecordMoney(float value)
{
char times[128] = {0}, pbuf[128] = {0}, disbuf[1024 * 2] = {0}, Sum[128] = {0};
LINKLIST *p;
LINKLIST1 *tp, *ts;
float sum = 0;
int cont = 0;
tp = Tmphead;

memset(disbuf, 0, sizeof(disbuf));
memset(pbuf, 0, sizeof(pbuf));
p = Listhead->next;
while (p != NULL)
{
if (value == p->Listdata.money)
{
ts = (LINKLIST1 *)malloc(sizeof(LINKLIST1));
ts->orde = cont;
memcpy(&ts->Listdata, &p->Listdata, sizeof(LIST_OUT_TABLE));
tp->next = ts;
tp = ts;
sprintf(times, "%d-%d-%d", (p->Listdata.wdata.Year) - 100 + 2000, (p->Listdata.wdata.Month) + 1, p->Listdata.wdata.Day);
sprintf(pbuf, "%10d%12s%15s%15s%18.2f\n", p->Listdata.no, times, SORT_Item[p->Listdata.sort - 1].sort_item, p->Listdata.items, p->Listdata.money);
strcat(disbuf, pbuf);
sum += p->Listdata.money;
cont ++;
}
memset(times, 0, sizeof(times));
p = p->next;
}
tp->next = NULL;
DisplayItem();
sprintf(Sum, "%54sTotal:%10.2f\n", " ", sum);
strcat(disbuf, Sum);
printf("%s\n", disbuf);

return cont;
}

int OndisplaychoiceInfo(int no)
{
LINKLIST1 *p;
int i = 0;
char times[128] = {0};
int ret;
p = Tmphead->next;

while (p != NULL)
{
if (p->orde == no)
{
memset(times, 0, sizeof(times));
sprintf(times, "%d-%d-%d", (p->Listdata.wdata.Year) - 100 + 2000, (p->Listdata.wdata.Month) + 1, p->Listdata.wdata.Day);
printf("%10d%12s%15s%15s%18.2f\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", p->Listdata.no, times, SORT_Item[p->Listdata.sort - 1].sort_item, p->Listdata.items, p->Listdata.money);
ret = p->Listdata.no;
}
p = p->next;
}
return ret;
}

void OnReOrder(void)
{
LINKLIST *p;
p = Listhead->next;
Global_i = 0;
while (p != NULL)
{
p->Listdata.no = Global_i;
Global_i ++;
p = p->next;
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-08-29
#include <iostream>
#include <list>
#include <string>
#include <iomanip>
#include <vector>

using namespace std;

class Contacts
{
public:
string getName() const;
string getSex() const;
string getAddress() const;
string getID() const;
string getTelnumber() const;
string getE_mail() const;

void setName(const string& s) { name = s; }
void setSex(const string& s) { sex = s; }
void setAddress(const string& s) { address = s; }
void setID(const string& s) { ID = s; }
void setTelnumber(const string& s) { telnumber =s; }
void setE_mail(const string& s) { E_mail= s; }
private:
string name;
string sex;
string address;
string ID;
string telnumber;
string E_mail;
};
string Contacts::getAddress() const
{
return address;
}

string Contacts::getE_mail() const
{
return address;
}

string Contacts::getID() const
{
return ID;
}

string Contacts::getName() const
{
return name;
}

string Contacts::getSex() const
{
return sex;
}

string Contacts::getTelnumber() const
{
return telnumber;
}

list<Contacts> con_list;

class ContactMgr
{
public:
// Contacts();
typedef list<Contacts>::iterator it_con;
void Insert();
void Edit();
void Delete();
void DisplayAll();
void QueryRes();
private:

it_con Query(string& name, it_con beg = con_list.begin(), it_con end = con_list.end());
it_con exactQuery(string& name, it_con beg = con_list.begin(), it_con end = con_list.end());
void single_Diplay(Contacts&) const;
Contacts Input();
};

Contacts ContactMgr::Input()
{
string s;
Contacts tmp;

cout << "Name: ";
cin >> s;
tmp.setName(s);

cout << "Sex: ";
cin >> s;
tmp.setSex(s);

cout << "Address: ";
cin >> s;
tmp.setAddress(s);

cout << "ID: ";
cin >> s;
tmp.setID(s);

cout << "TelNumber: ";
cin >> s;
tmp.setTelnumber(s);

cout << "Email: ";
cin >> s;
tmp.setE_mail(s);

return tmp;

}

void ContactMgr::single_Diplay(Contacts& con) const
{
cout << setw(10) << "Name: " << con.getName() << endl;
cout << setw(10) << "Sex: " << con.getSex() << endl;
cout << setw(10) << "Address: " << con.getAddress() << endl;
cout << setw(10) << "ID: " << con.getID() << endl;
cout << setw(10) << "TelNumber: " << con.getTelnumber() << endl;
cout << setw(10) << "Email: " << con.getE_mail() << endl;
}

void ContactMgr::Insert()
{
Contacts in = Input();
string q_name = in.getName();
if (exactQuery(q_name) != con_list.end())
{
cout << "\n----------------------------------------" << endl;
cout << "ERROR: Try to insert an exsiting contact person!" << endl;
cout << "----------------------------------------\n" << endl;
return ;
}

con_list.insert(con_list.end(), in);
cout << "\n----------------------------------------" << endl;
cout << "Insert successsfully! " << endl;
cout << "----------------------------------------\n" << endl;
}

list<Contacts>::iterator ContactMgr::Query(string& name, it_con beg,
it_con end)
{
it_con it = beg;

while (it != end)
{
if ((it->getName()).find(name) != string::npos)
break;
++it;
}

return it;
}

list<Contacts>::iterator ContactMgr::exactQuery(string& name, it_con beg,
it_con end)
{
it_con it = beg;

while (it != end)
{
if (it->getName() == name)
break;
++it;
}

return it;
}

void ContactMgr::Edit()
{
string name;
cout << "Input the contact person's name you want to edit: " << endl;
cin >> name;

it_con tmp;
if ((tmp = exactQuery(name)) != con_list.end())
{
cout << "Input new contact: " << endl;
string s;
cout << "Sex: ";
cin >> s;
tmp->setSex(s);

cout << "Address: ";
cin >> s;
tmp->setAddress(s);

cout << "ID: ";
cin >> s;
tmp->setID(s);

cout << "TelNumber: ";
cin >> s;
tmp->setTelnumber(s);

cout << "Email: ";
cin >> s;
tmp->setE_mail(s);

cout << "\n----------------------------------------" << endl;
cout << "Edit successfully! " << endl;
cout << "----------------------------------------\n" << endl;
}
else
{
cout << "\n----------------------------------------" << endl;
cout << "Contact person not found !" << endl;
cout << "----------------------------------------\n" << endl;
}
}

void ContactMgr::Delete()
{
string name;
cout << "Input the contact person's name you want to edit: " << endl;
cin >> name;

it_con tmp;
if ((tmp = exactQuery(name)) != con_list.end())
{
con_list.erase(tmp);
cout << "\n----------------------------------------" << endl;
cout << "Delete successfully! " << endl;
cout << "----------------------------------------\n" << endl;
}
else
{
cout << "\n----------------------------------------" << endl;
cout << "Contact person not found !" << endl;
cout << "----------------------------------------\n" << endl;
}
}

void ContactMgr::DisplayAll()
{
system("cls");
cout << "\n\nThere are totally " << con_list.size() << " records in the Concacts! " << endl;
it_con it = con_list.begin();
while (it != con_list.end())
{

cout << "\n----------------------------------------" << endl;
single_Diplay(*it);
cout << "----------------------------------------\n" << endl;
++it;
system("pause");
system("cls");

}
}

void ContactMgr::QueryRes()
{
string name;
cout << "Enter the name you want to Query: ";
cin >> name;

vector<Contacts> con_vec;
it_con it = con_list.begin();
while (it != con_list.end())
{
it = Query(name, it);
if (it != con_list.end())
{
con_vec.push_back(*it);
++it;
}

}

cout << "\n" << con_vec.size() << " records found!" << endl;

vector<Contacts>::iterator it_vec = con_vec.begin();
while (it_vec != con_vec.end())
{
cout << "----------------------------------------" << endl;
single_Diplay(*it_vec);
cout << "----------------------------------------\n" << endl;
++it_vec;
}
}

int main()
{
ContactMgr mgr;
cout << "***************************************" << endl;
cout << "* Welcome to the easy Contact Manager!*" << endl;
cout << "***************************************" << endl;

bool flag = true;
while (flag)
{
cout << "\n\nenter the action U want to take";
cout << "\n'I' for inser, \n'E' for edit, \n'D' for delete,\n'Q' for query, \n'S' for show all, \nothers for out(exit):" ;

char action;
cin >> action;
switch (action)
{
case ('I'):
case ('i'): mgr.Insert();break;

case ('E'):
case ('e'): mgr.Edit();break;

case ('D'):
case ('d'): mgr.Delete();break;

case ('Q'):
case ('q'): mgr.QueryRes();break;

case ('S'):
case ('s'): mgr.DisplayAll();break;

default:
flag = false;break;
}

}
return 0;
}

STL的简单应用。本回答被提问者采纳
第2个回答  2008-08-28
编这种涉及到数据库管理的程序很费脑筋的,特别是学籍管理程序,工程量太浩大了,估计这里没多少人能给你吧。给你提个建议,你可以到一些编程论坛上看看,说不定能找到,要不就搜一下那些开放源代码的资源。
第3个回答  2008-08-29
加我百度HI,可以写.
相似回答
大家正在搜