五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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語言版)的評論 (共 條)

分享到微博請遵守國家法律
盖州市| 民县| 高安市| 张掖市| 宁都县| 常熟市| 剑川县| 保山市| 新乐市| 隆化县| 太和县| 九龙城区| 磴口县| 美姑县| 拉萨市| 左权县| 称多县| 岳阳县| 格尔木市| 吴旗县| 武邑县| 宝兴县| 武乡县| 大荔县| 涿鹿县| 会宁县| 江陵县| 巴彦县| 定边县| 静乐县| 巴马| 甘肃省| 乌拉特中旗| 五大连池市| 临夏县| 双牌县| 岢岚县| 娱乐| 台湾省| 招远市| 灵台县|