当前位置:网站首页>Classic example of C language - commodity inspection code
Classic example of C language - commodity inspection code
2022-07-24 00:26:00 【Blue_ lan18】

Numbers 013800 15173 5 Appears below the barcode . The first 1 A number indicates the type of goods ( Most goods use o perhaps 7 Express ,2 Indicates the goods to be weighed ,3 It means drugs or health-related goods , and 5 Indicates a gift ). The first group 5 Bits are used to identify the manufacturer (13800 It is the code of Nestle frozen food company in the United States ). The second group 5 Digit numbers are used to identify the product ( Including package size ). The last digit is “ Check bit ”, Its only purpose is to help identify errors in the preceding numbers . If there is an error in barcode scanning , So before 11 Digit numbers may not match the last digit , Supermarket scanners will reject the entire barcode .
Here's a way to calculate check bits : First of all 1 position 、 The first 3 position 、 The first 5 position 、 The first 7 position 、 The first 9 Position and number 11 Digit number
Add up ; And then put the 2 position 、 The first 4 position 、 The first 6 position 、 The first 8 Position and number 10 Add the digits ; Take a look at my brother's one-time addition of Luo song to , Then add it to the result of the second addition ; Then subtract from the above result 1; The result of subtraction is divided by 10 Take the remainder ; Last use 9
Subtract the remainder from the previous step .
# include <stdio.h>
int main()
{
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11;
int firstResult = 0, secondResult = 0, thirdResult = 0, fourResult = 0;//fourResult It is the inspection code
printf("Please enter 11 numbers: ");
scanf("%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d", &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10, &a11);
firstResult = a1 + a3 + a5 + a7 + a9 + a11;
secondResult = a2 + a4 + a6 + a8 + a10;
thirdResult = 3 * firstResult + secondResult;
fourResult = 9 - (thirdResult - 1) % 10;
printf("a11 = %d\n", fourResult);
return 0;
}
边栏推荐
- Gbase 8C system table information function (II)
- Gbase 8C mode visibility query function (2)
- Customize an object
- Gbase 8C string operator
- Lac automatic dialing experiment of L2TP
- [video game training] non contact object size and shape measurement 2020 video game G
- Distributed cap principle
- Gbase 8C session information function (V)
- IT基础英语
- Redis主从同步机制
猜你喜欢

docker 拉取redis镜像 并运行

Docker pulls the redis image and runs it

Application of SCA on devsecops platform

二叉搜索树的简易实现及剖析

Don't let Fujin Yibo see this

书写SQL必养成的好习惯

mongodb的多数据源配置

Tencent cloud was affirmed by international professional streaming media evaluation: video coding performance is the best in all three scenarios
![[wechat applet] design and interactive implementation of auction product details page (including countdown and real-time update of bids)](/img/b5/dd4316b83ef4b80c36b532de658bb2.png)
[wechat applet] design and interactive implementation of auction product details page (including countdown and real-time update of bids)

数仓数据标准详解-2022
随机推荐
php实现 Stripe订阅
Gbase 8C binary string operator
GBase 8c 会话信息函数(三)
GBase 8c 会话信息函数(二)
paypal订阅流程及api请求
Redis master-slave synchronization mechanism
Summary of pit websocket
GBase 8c 位串操作符(一)
Intelligent OCR identification of express documents helps the logistics industry to upgrade Digitalization
ES6 combines multiple class methods
【电赛训练】非接触物体尺寸形态测量 2020年电赛G题
泛型机制和增强for循环
[low code] limitations of low code development
Gbase 8C session information function (4)
Gbase 8C bit string operator (I)
Redis数据结构
GBase 8c系统表信息函数(二)
Reverse linked list drawing demonstration
inode、软链接、硬链接
Application of SCA on devsecops platform