C语言超市商品管理1.pdfVIP

  • 3
  • 0
  • 约8.43千字
  • 约 8页
  • 2021-12-11 发布于河北
  • 举报
这套程序名为“超市商品管理程序” 这套程序是为超市进行商品管理所设计的 ,程序可以实现商品录入 ,原有商品信息 修改以及删除商品信息等简单基本的功能 .这套程序是通过数组的方式实现对商 品 的名称 ,序 列号 , 价格 进 行管 理的 .程 序在 windows7 旗 舰版 和 Visual C++2008 环境下完成编写及调试 程序的结构包括商品信息录入模块 ,商品信息修改模块,商品信息删除模块,文 件写入及读出模块,用户界面等组成。程序在 Visual C++2008 环境下运行。 程序代码: // 商品信息管理 .cpp : 定义控制台应用程序的入口点。 // #include stdio.h #include stdafx.h #include string.h #include stdlib.h /* 定义商品结构体 */ struct Item { char ID[20],Name[20],Price[20]; }; /* 声明商品数组及商品数量 */ struct Item items[100]; int num=0; /* 通过序列号返回数组下标 */ int Item_SearchByIndex( char id[]) { int i; for (i=0;inum;i++) { if (strcmp(items[i].ID,id)==0) { return i; } } return -1; } /* 显示单条商品记录 */ void Item_DisplaySingle( int index) { printf( %8s%6s%6s\n, 序列号 , 名称 , 价格 ); printf( \n ); printf( %8s%6s%6s\n,items[index].ID,items[index].Name,items[index].Price); } /* 插入商品信息 */ void Item_Insert() { while (1) { printf( 请输入序列号 : ); scanf_s( %s ,items[num].ID); getchar(); printf( 请输入姓名 : ); scanf_s( %s ,items[num].Name); getchar(); printf( 请输入性别 : ); scanf_s( %s ,items[num].Price); getchar(); printf( 是否继续 ?(y/n) ); if (getchar()== n ) {system( cls ); break ;

文档评论(0)

1亿VIP精品文档

相关文档