-->
当前位置:首页 > 题库

PROGRAMMING:Unified code of verification commodity

Luz5年前 (2021-05-10)题库391
Universal product code (UPC) is an international bar code application system for retail products. The most commonly used UPC code is composed of 12 digits * * decimal number * *: the first digit is used to code the commodity type, the next five digits are used to represent the manufacturer, the last five digits are used to represent the special commodity, and the last one is the check code. UPC codes can be verified by the following methods:
1. First of all, sum the bits of UPC code according to the following formula:
$$3x_ 1+x_ 2+3x_ 3+x_ 4+3x_ 5+x_ 6+3x_ 7+x_ 8+3x_ 9+x_{ 10}+3x_{ 11}+x_{ 12}$$
2. Take the remainder of the sum result for $$10 $. If the remainder is $$0 $, it means that the UPC code is a valid commodity code. Otherwise, it is not a valid UPC code.
###Input format:
Input the first line to give a positive integer n (≤ 10) is the number of input UPC codes. Then n lines, each line gives a 12 bit UPC code.
###Output format:
According to the order of input, output one problematic UPC code per line** It does not check whether the first 11 bits are reasonable, but only check whether the first 11 bits are all numbers, and the last check code is calculated accurately** If all encoding is normal, output 'all passed'.
###Input sample 01:
```in
one
seven hundred and ninety-three billion five hundred and seventy-three million four hundred and thirty-one thousand and forty-two
```
###Output sample 01:
```out
All passed
```
###Input sample 02:
```in
two
seven hundred and ninety-three billion five hundred and seventy-three million four hundred and thirty-one thousand and forty-two
041331021641
```
###Output sample 02:
```out
041331021641
```
###Input sample 03:
```in
three
08960012456X
eight hundred and eleven billion five hundred and seventy-one million thirteen thousand five hundred and seventy-nine
18B114771211
```
###Output sample 03:
```out
08960012456X
18B114771211
```







answer:If there is no answer, please comment