#include <stdio.h>
#include <string.h>
typedef struct ln //会员信息
{
char id[20]//会员账号
char key[20]//会员密码
int sum//会员积分
struct ln *next
} member
struct lm//商品信息
{
int id//商品编号
char name[50]//商品名称
int stock//商品库存
} goods[1000]
member *registe(member *t)//注册
void buy()
int main()
{
member *head=(member *)malloc(sizeof(member))
strcpy(head->id, "0"), strcpy(head->key, "0")//超市管理员
head->next=NULL
int i, a, n, boo=0
while(1)
{
printf(" 注册会员请按1:\n")
printf(" 会员直接登录请按2:\n")
printf(" 退出请按0:\n")
scanf("%d", &a)
if(a==0) break
if(a==1) head=registe(head)
else if(a==2) boo=login(head)
if(boo) break
}
if(a &&boo==1)
{
printf(" 尊贵的会员,您登录成功!\n")
buy()
}
printf(" 已经安全退出\n")
}
member *registe(member *t)//注册
{
printf(" 现在开始会员注册\n\n")
char id[20], key[20]
member *p, *q, *r
p=t
while(p->next) p=p->next//寻找链表中最后一个结点
while(1)
{
printf(" 请输入您注册的账号,密码:\n")
scanf("%s %s", id, key)
q=t
while(q)//判断该账号是否已经被注册
{
if(strcmp(q->id, id)==0) break
else q=q->next
}
只要输出在屏幕上么#include <stdio.h>
#define PRICE 1.5
main()
{
int n
double s
printf("请输入你购买产品数量(单位:瓶):")
scanf("%d",&n)
printf("请输入你支付的现金(单位:元):")
scanf("%lf",&s)
printf("购货清单\n")
printf("---------------------------------------------------------\n")
printf("商品名称\t数量\t小计\n")
printf("矿泉水\t%d\t%.2lf\n",n,n*PRICE)
printf("---------------------------------------------------------\n")
printf("总计\t%.2lf\n",n*PRICE)
printf("支付金额:%.2lf\n",s)
printf("找零:%.2lf\n",s-n*PRICE)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)