当前位置: 首页 > news >正文

网站wordpress是什么意思怎么做网站广告古董

网站wordpress是什么意思,怎么做网站广告古董,百度电话销售,民宿设计公司从一个简单的超市收银系统#xff0c;我们来练习一个系统如何设计#xff0c;然后如何实现的思路。 在Ubuntu环境下使用C语言编写一个简单的超市收银系统。以下是一个基本的示例#xff0c;涵盖了商品管理、购物车、交易处理等功能。 代码 #include stdio.h #inc…从一个简单的超市收银系统我们来练习一个系统如何设计然后如何实现的思路。 在Ubuntu环境下使用C语言编写一个简单的超市收银系统。以下是一个基本的示例涵盖了商品管理、购物车、交易处理等功能。 代码 #include stdio.h #include stdlib.h// 商品结构体 struct Product {int id;char name[50];float price; };// 购物车项结构体 struct ShoppingCartItem {struct Product product;int quantity; };// 交易结构体 struct Transaction {struct ShoppingCartItem *items;int itemCount; };// 商品管理结构体 struct Inventory {struct Product *products;int productCount; };// 初始化商品管理系统 struct Inventory initializeInventory() {struct Inventory inventory;inventory.products NULL;inventory.productCount 0;return inventory; }// 添加商品到库存 void addProduct(struct Inventory *inventory, struct Product product) {inventory-products realloc(inventory-products, (inventory-productCount 1) * sizeof(struct Product));inventory-products[inventory-productCount] product; }// 显示库存信息 void displayInventory(struct Inventory inventory) {printf(Inventory:\n);for (int i 0; i inventory.productCount; i) {printf(%d. %s - $%.2f\n, inventory.products[i].id, inventory.products[i].name, inventory.products[i].price);} }// 获取商品信息 struct Product getProductInfo(struct Inventory inventory, int productId) {for (int i 0; i inventory.productCount; i) {if (inventory.products[i].id productId) {return inventory.products[i];}}struct Product notFound;notFound.id -1;return notFound; }// 初始化交易 struct Transaction initializeTransaction() {struct Transaction transaction;transaction.items NULL;transaction.itemCount 0;return transaction; }// 添加商品到购物车 void addToCart(struct Transaction *transaction, struct Product product, int quantity) {transaction-items realloc(transaction-items, (transaction-itemCount 1) * sizeof(struct ShoppingCartItem));transaction-items[transaction-itemCount].product product;transaction-items[transaction-itemCount].quantity quantity;transaction-itemCount;printf(Added %d %s(s) to the cart.\n, quantity, product.name); }// 显示购物车 void displayCart(struct Transaction transaction) {float total 0.0;printf(Shopping Cart:\n);for (int i 0; i transaction.itemCount; i) {struct ShoppingCartItem item transaction.items[i];printf(%s - Quantity: %d\n, item.product.name, item.quantity);total item.product.price * item.quantity;}printf(Total Price: $%.2f\n, total); }// 完成交易 void completeTransaction(struct Transaction transaction) {printf(Transaction completed. Thank you!\n);free(transaction.items); }int main() {struct Inventory inventory initializeInventory();// 添加一些商品addProduct(inventory, (struct Product){1, Milk, 2.5});addProduct(inventory, (struct Product){2, Bread, 1.0});addProduct(inventory, (struct Product){3, Eggs, 3.0});struct Transaction transaction initializeTransaction();// 超市收银系统while (1) {displayInventory(inventory);int productId;printf(Enter product ID to add to cart (or 0 to finish): );scanf(%d, productId);if (productId 0) {break;}struct Product product getProductInfo(inventory, productId);if (product.id ! -1) {int quantity;printf(Enter quantity: );scanf(%d, quantity);addToCart(transaction, product, quantity);} else {printf(Product not found.\n);}}displayCart(transaction);completeTransaction(transaction);// 释放资源free(inventory.products);return 0; }编译 gcc supermarket.c -o supermarket ./supermarket程序设计的详细过程 步骤 1: 定义数据模型 在程序设计的起始阶段定义了程序需要用到的数据模型包括商品、购物车项和交易。使用结构体表示这些概念其中包括商品Product、购物车项ShoppingCartItem和交易Transaction。 struct Product {int id;char name[50];float price; };struct ShoppingCartItem {struct Product product;int quantity; };struct Transaction {struct ShoppingCartItem *items;int itemCount; };步骤 2: 商品管理 设计商品管理系统包括添加商品到库存和获取商品信息的功能。使用结构体 Inventory 来保存商品信息并定义相应的函数。 struct Inventory {struct Product *products;int productCount; };// 添加商品到库存 void addProduct(struct Inventory *inventory, struct Product product) {// 通过realloc动态分配内存以保存商品inventory-products realloc(inventory-products, (inventory-productCount 1) * sizeof(struct Product));inventory-products[inventory-productCount] product; }// 获取商品信息 struct Product getProductInfo(struct Inventory inventory, int productId) {for (int i 0; i inventory.productCount; i) {if (inventory.products[i].id productId) {return inventory.products[i];}}struct Product notFound;notFound.id -1;return notFound; }步骤 3: 用户界面 设计用户界面实现基本的用户交互允许用户选择商品并添加到购物车。使用结构体 CashierUI 和相应的函数。 struct CashierUI {struct Inventory inventory;struct Transaction transaction; };// 显示库存信息 void displayInventory(struct Inventory inventory) {// 输出商品列表 }// 添加商品到购物车 void addToCart(struct Transaction *transaction, struct Product product, int quantity) {// 将商品添加到购物车 }// 显示购物车信息 void displayCart(struct Transaction transaction) {// 输出购物车内容 }// 完成交易 void completeTransaction(struct Transaction transaction) {// 输出总价和完成交易信息 }步骤 4: 交易处理 实现交易处理功能计算购物车中商品的总价并完成交易。 // 初始化交易 struct Transaction initializeTransaction() {struct Transaction transaction;transaction.items NULL;transaction.itemCount 0;return transaction; }// 完成交易 void completeTransaction(struct Transaction transaction) {// 输出总价和完成交易信息// 释放购物车内存free(transaction.items); }步骤 5: 主程序 在主程序中创建超市收银系统实例添加一些商品然后启动收银系统。 int main() {// 初始化商品管理系统struct Inventory inventory initializeInventory();// 添加一些商品addProduct(inventory, (struct Product){1, Milk, 2.5});addProduct(inventory, (struct Product){2, Bread, 1.0});addProduct(inventory, (struct Product){3, Eggs, 3.0});// 初始化交易struct Transaction transaction initializeTransaction();// 超市收银系统while (1) {// 显示库存信息displayInventory(inventory);int productId;printf(Enter product ID to add to cart (or 0 to finish): );scanf(%d, productId);if (productId 0) {break;}// 获取商品信息struct Product product getProductInfo(inventory, productId);if (product.id ! -1) {int quantity;printf(Enter quantity: );scanf(%d, quantity);// 添加商品到购物车addToCart(transaction, product, quantity);} else {printf(Product not found.\n);}}// 显示购物车displayCart(transaction);// 完成交易completeTransaction(transaction);// 释放资源free(inventory.products);return 0; }这个设计过程包括了程序的整体结构、数据模型的定义、功能的实现以及用户界面的设计。当设计一个更大规模的系统时可能需要考虑更多的功能例如支付处理、库存管理、用户认证等。这个简化的例子提供了一个基本的框架可以根据实际需求进行扩展。
http://www.dnsts.com.cn/news/74958.html

相关文章:

  • 如何做网站平台销售wordpress 导购主题
  • 网站正在建设中源码网页游戏网站官网
  • 厦门市建设局查询保障摇号网站农村自建房设计图一层
  • html5手机网站特效深圳个人网站建设
  • 南昌网站建设kaiu安徽网站设计费用
  • 建设网站的安全性介绍网络规划设计师报名
  • 温州瓯海区营销型网站建设西安互联网网站建设
  • 徐州营销型网站制使网站建设播放vr视频
  • 厦门网站建设xm37wordpress 演示站
  • 河南省网站建设意见网站开发的上市公司有哪些
  • 网站开发与建设的原则开发者模式要不要开
  • 中核工建设集团有限公司网站做网站空
  • 小店怎么做网站科技公司取名大全
  • 北京做网站建设的公司个人可以备案网站的内容
  • 阿里云网站建设方案书是什么苏州公司建站
  • 东阿做网站建一个网站要多少钱
  • 网站500m空间价格婴幼儿网站模板
  • 南浔哪有做网站的怎么做好网络推广销售
  • 西安专业房产网站建设李沧做网站
  • 网站建设与维护方式大专ui设计师工资一般多少
  • 广州哪里有做网站推广企业管理系统的构成状况
  • 深圳网站设计服务找哪家邯郸服务
  • pc端网站建设联系方式私募基金公司网站建设
  • 重庆建站公司哪个好丹东黄页网
  • 甘肃省建设类证书查询网站株洲建设局网站
  • 建站公司 网络服务松原建设局网站
  • 福建住房与城乡建设部网站宝安-网站建设信科网络
  • 互联网站点全网营销新胜天下
  • 重庆企业建站模板帮小公司代账一个月费用
  • 网站数据库设计模板北京广告设计制作公司