销售员业绩管理程序设计

xiaoxiao2021-02-28  87

#include<stdio.h> #include<string.h> #include<stdlib.h> int n = 0; struct a { long int num; char name[20]; char producename[20]; float price; float quantity; float salvesvolume; }; void funx(struct a *stu) { char c[2]; printf("输入数据:"); do { printf("\n第%d位销售员编号:", n + 1); scanf("%ld", &stu[n].num); printf("姓名:"); scanf("%s", stu[n].name); printf("销售产品名:"); scanf("%s", stu[n].producename); printf("销售员销售的产品单价,销售数量:"); scanf("%f,%f", &stu[n].price, &stu[n].quantity); stu[n].salvesvolume = stu[n].quantity*stu[n].price; n++; printf("继续输入数据请按Y或y:"); scanf("%s", c); } while (!(strcmp(c, "Y")) || !(strcmp(c, "y"))); }  void funn(struct a *stu) { int i; printf("输出数据:"); for (i = 0;  i< n; i++) { printf("\n第%d位销售员编号:", i + 1); printf("%ld\n", stu[i].num); printf("姓名,销售产品名:"); printf("%s%s\n", stu[i].name, stu[i].producename); printf("销售员销售的产品单价,销售数量:"); printf("%f,%f\n", stu[i].price, stu[i].quantity); printf("销售额:"); printf("%f\n", stu[i].salvesvolume); } } void funm(struct a *stu,char x[]) { int i; for (i=0; i < n; i++) { if (strcmp(stu[i].name,x)==0) printf("该销售员销售记录:\n销售产品名%s\n,销售产品单价%f\n,销售产品数量%f\n,销售额:%f\n", stu[i].producename, stu[i].price, stu[i].quantity, stu[i].salvesvolume); } } main() { char x[20]; struct a stu[100]; int menu; while (1) { printf("1.输入:输入数据\n"); printf("2.显示:显示所有记录\n"); printf("3.查询:输入姓名,显示销售员记录\n"); printf("4.结束"); printf("select input 1-4:\n"); scanf("%d", &menu); switch (menu) { case 1:funx(stu); break; case 2:funn(stu); break; case 3: { printf("请输入要查询的销售员姓名:\n"); scanf("%s",x); funm(stu,x); break; } case 4:exit(0); } } }
转载请注明原文地址: https://www.6miu.com/read-39360.html

最新回复(0)