fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. char to_hex(char i)
  5. {
  6. if(i >= 16 || i < 0) return 0;
  7. else if(i >= 10) return i - 10 + 'A';
  8. else return i + '0';
  9. }
  10.  
  11.  
  12. int main() {
  13. // your code goes here
  14.  
  15. cout<<to_hex(10)<<' '<<to_hex(1)<<' '<<to_hex(100)<<endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
A 1