记录第一次系统地写下一个实用代码
/*1.插入一条记录,包括需要采购物品的名称,采购的数量,单价,采购地点到商场的距离,用一个结构体实现。
2.对所有需要采购的物品按距离进行的排序。
3.对所有需要采购的物品按名称字典序进行的排序。
4.删除一条记录,按时间删除和按物品名删除。
5.查找对应时间需要采购的物品。
6.按物品名称查找相关信息(扩展需求:模糊搜索,比如名称为abc,输入a或输入b,也可显示该记录)。
7.修改某个物品需要采购的数量,单价。
8.到点提醒,到确切的时间,提醒老刘去采购相应的物品(获取系统时间即可)。*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <windows.h>
#include <process.h>
#define output "||||name:%s||number:%d||price:%.2lfyuan||place:%s||distance:%.2lfkm||time:%02do'clock||%02dminutes||%02dseconds||||\n"
#define DATA p->data.name,p->data.num,p->data.price,p->data.place,p->data.distance,p->data.hours,p->data.minutes,p->data.seconds
//定义购买清单结构体
struct item{
char name[30];
int num;
double price;
char place[30];
double distance;
int hours;
int minutes;
int seconds;
};
//定义链表
typedef struct Node{
struct item data;/*存放数据*/
struct Node* next;/*指针*/
}node,*head;
head l;
int ch;
/*菜单、进入界面
1.增添一条购物清单
2.删除一条购物清单
3.更改一条购物清单
4.输入时间来找到购物物品
5.输入物品名称来找到购物清单记录
6.按照距离排序
7.按照字典序排序
8.闹钟提醒服务*/
void list(){
printf("Welcome to the shopping listing!\n");
printf("Please enter a number as follows if you want to use the program:\n");
printf("1.Add a shopping record.\n");
printf("2.Delete a shopping record.\n");
printf("3.Modify a shopping record.\n");
printf("4.Enter the time to find the item.\n");
printf("5.Enter the name of the item to find the shopping records.\n");
printf("6.Sort by distance.\n");
printf("7.Sort in alphabetical order\n");
printf("I have alarm service~\n");
printf("Hope you enjoy using the programe\(^o^)/~\n");
printf("Please enter a number:\n");
}
//增添一条购物清单的函数
void add_list(void){
system("CLS");
char na[30],pl[30];
int nu,ho,mi,se;
double pr,di;
node *p,*last;