Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- void CheckIfCodeValid( int siza);
- int main()
- {
- int Choice;
- while (1)
- {
- int ControlNumber = 0;
- long S = 0;
- int CNumber = 0;
- const short Size1 = 8;
- const short Size2 = 13;
- cout << "Menu" << endl;
- cout << "Wybierz rodzaj kodu kreskowego" << endl;
- cout << "\t1. EAN-8."
- << "\n\t2. EAN-13."
- << "\n\t9 By zakonczyc program"<<endl;
- cin >> Choice;
- switch (Choice)
- {
- case 1:
- char BarCode[13];
- int BarCode1[13];
- cout << "Wprowadz swoj kod" << endl;
- cin >> BarCode;
- for (int i = 0; i < 13; i++)
- {
- BarCode1[i] = BarCode[i] - '0';
- }
- for (int i = 1; i < Size1; i++)
- {
- S += ((2 - pow(-1, i)) * BarCode1[i - 1]);
- }
- ControlNumber = 10 - (S % 10);
- cout << BarCode1[Size1-1] << endl;
- cout << S << endl;
- cout << ControlNumber << endl;
- if (ControlNumber == BarCode1[7])
- {
- cout << "\n Valid bar code";
- }
- else
- {
- cout << "\n Invalid bar code";
- cout << "\n Valid Barcode is: " << endl;
- BarCode1[7] = ControlNumber;
- for (int i = 0; i < 8; i++)
- {
- cout << BarCode1[i];
- }
- }
- case 2:
- //CheckIfCodeValid(13);
- case 9:
- exit(1);
- default:
- break;
- }
- }
- }
- void CheckIfCodeValid(int Size)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement