fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <algorithm>
  5.  
  6. using std::string;
  7. using std::cout;
  8. using std::cin;
  9. using std::endl;
  10. using std::istringstream;
  11.  
  12. int main() {
  13. string nums = "8060";
  14. string input;
  15. cin >> input;
  16.  
  17. if( input.substr(0,4) != "SKY-") {
  18. return 1;
  19. }
  20.  
  21. bool b;
  22. transform(input.begin()+4, input.end()-5, input.begin()+4, ::tolower);
  23. cout << "b is " << b;
  24. if( istringstream(input.substr(4,4)) >> std::boolalpha >> b && b ) {
  25. for( int i = 9; i < input.size(); i++ ) {
  26. if( ((int)input[i] - 48 << 6) % 10 != (int)nums[i-9] - 48 ) {
  27. cout << "i is " << i;
  28. return 1;
  29. }
  30. }
  31.  
  32.  
  33. cout << "Correct!" << endl;
  34. }
  35.  
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 5444KB
stdin
SKY-ACKE-8060
stdout
b is 0