Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cctype>
- using namespace std;
- int main()
- {
- string in;
- while(cin>>in)
- {
- string ori=in;
- for(int i=0;i<in.length();i++)
- {
- if (in[i]=='-')
- {
- in.erase(i,1);
- }
- }
- int check=0;
- for(int i=0;i<9;i++)
- {
- check+=(in[i]-'0')*(i+1);
- //cout<<"***chcke="<<check<<endl;
- }
- check%=11;
- if(check==10)
- {
- if(in[9]=='X')
- {
- cout<<"OK"<<endl;
- }
- else
- {
- ori[ori.length()-1]='X';
- cout<<ori<<endl;
- }
- }
- else
- {
- if(check==(in[9]-'0'))
- {
- cout<<"OK"<<endl;
- }
- else
- {
- ori[ori.length()-1]=('0'+check);
- cout<<ori<<endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement