国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

便利店商品管理系統(tǒng)(C語言版)

2023-05-23 13:09 作者:Developer999  | 我要投稿

#include <stdio.h>

#include <stdlib.h>

#include <string.h>


typedef struct {

? ? int id;? ? ? ? ? ? ?// 商品編號

? ? char name[20];? ? ? // 商品名稱

? ? float price;? ? ? ? // 商品價格

? ? int quantity;? ? ? ?// 商品數(shù)量

} Product;


// 添加新商品到庫存列表

void addProduct(Product* productList, int* count) {

? ? printf("添加新品:\n");


? ? productList[*count].id = *count + 1;


? ? printf("請輸入商品名字:");

? ? scanf("%s", productList[*count].name);

? ??

? ? printf("請輸入價格:");

? ? scanf("%f", &productList[*count].price);


? ? printf("請輸入數(shù)量:");

? ? scanf("%d", &productList[*count].quantity);


? ? (*count)++;

? ? printf("添加成功!\n");

}


// 顯示庫存列表

void displayProducts(Product* productList, int count) {

? ? printf("庫存列表:\n\n");

? ? printf("編號\t名稱\t價格\t數(shù)量\n");

? ? for (int i = 0; i < count; i++) {

? ? ? ? printf("%d\t%s\t%.1f\t%d\n", productList[i].id, productList[i].name,?

? ? ? ? ? ? productList[i].price, productList[i].quantity);

? ? }

}


// 刪除指定編號的商品

void removeProduct(Product* productList, int* count) {

? ? int productId;

? ? displayProducts(productList, *count);

? ? printf("輸入編號刪除:");

? ? scanf("%d", &productId);


? ? if (productId <= 0 || productId > *count) {

? ? ? ? printf("無效編號!\n");

? ? ? ? return;

? ? }


? ? for (int i = productId-1; i < *count-1; i++) {

? ? ? ? productList[i] = productList[i+1];

? ? }

? ? (*count)--;

? ? printf("刪除成功!\n");

}


// 修改指定編號的商品

void updateProduct(Product* productList, int count) {

? ? int productId;

? ? displayProducts(productList, count);

? ? printf("輸入編號修改:");

? ? scanf("%d", &productId);


? ? if (productId <= 0 || productId > count) {

? ? ? ? printf("無效編號!\n");

? ? ? ? return;

? ? }


? ? printf("請輸入名稱:");

? ? scanf("%s", productList[productId-1].name);

? ? printf("請輸入價格:");

? ? scanf("%f", &productList[productId-1].price);

? ? printf("請輸入數(shù)量:");

? ? scanf("%d", &productList[productId-1].quantity);

? ? printf("修改成功!\n");

}


// 超市管理系統(tǒng)主函數(shù)

int main() {

? ? Product productList[100]; // 最多存儲100個商品

? ? int productCount = 0;? ? ?// 實際商品數(shù)量

? ? int choice;


? ? while (1) {

? ? ? ? printf("------------------\n");

? ? ? ? printf("1. 添加新商品\n");

? ? ? ? printf("2. 查看庫存列表\n");

? ? ? ? printf("3. 刪除指定商品\n");

? ? ? ? printf("4. 修改指定商品\n");

? ? ? ? printf("5. 退出程序\n");

? ? ? ? printf("------------------\n");


? ? ? ? printf("請選擇您的操作:");

? ? ? ? scanf("%d", &choice);


? ? ? ? switch (choice) {

? ? ? ? ? ? case 1:

? ? ? ? ? ? ? ? addProduct(productList, &productCount);

? ? ? ? ? ? ? ? break;

? ? ? ? ? ? case 2:

? ? ? ? ? ? ? ? displayProducts(productList, productCount);

? ? ? ? ? ? ? ? break;

? ? ? ? ? ? case 3:

? ? ? ? ? ? ? ? removeProduct(productList, &productCount);

? ? ? ? ? ? ? ? break;

? ? ? ? ? ? case 4:

? ? ? ? ? ? ? ? updateProduct(productList, productCount);

? ? ? ? ? ? ? ? break;

? ? ? ? ? ? case 5:

? ? ? ? ? ? ? ? printf("感謝使用!\n");

? ? ? ? ? ? ? ? exit(0);

? ? ? ? ? ? default:

? ? ? ? ? ? ? ? printf("無效選擇!\n");

? ? ? ? }

? ? }


? ? return 0;

}


便利店商品管理系統(tǒng)(C語言版)的評論 (共 條)

分享到微博請遵守國家法律
嘉荫县| 宜黄县| 永济市| 巴南区| 石台县| 噶尔县| 蒙城县| 英吉沙县| 江达县| 道真| 天柱县| 吴川市| 邛崃市| 定襄县| 新晃| 尖扎县| 河北省| 沙湾县| 元阳县| 陇西县| 敦化市| 华蓥市| 遵义县| 铜川市| 财经| 古浪县| 区。| 舒城县| 大冶市| 额尔古纳市| 双峰县| 阜康市| 梨树县| 麦盖提县| 攀枝花市| 开江县| 临邑县| 彭水| 永福县| 大城县| 上栗县|