fork download
  1. #include <string>
  2. #include <sstream>
  3. #include <iostream>
  4.  
  5. using std::string;
  6. using std::stringstream;
  7.  
  8. class Problem {
  9. public:
  10. static string indexB(int i, int j, int k);
  11. };
  12.  
  13. string Problem::indexB(int i, int j, int k){
  14.  
  15. stringstream ss;
  16.  
  17. if(i < 10)
  18. ss << "00";
  19. else if(i<100)
  20. ss << "0";
  21. ss << i;
  22.  
  23. if(j < 10)
  24. ss << "00";
  25. else if(j<100)
  26. ss << "0";
  27. ss << j;
  28.  
  29. if(k < 10)
  30. ss << "00";
  31. else if(k<100)
  32. ss << "0";
  33. ss << k;
  34.  
  35. return ss.str();
  36. }
  37.  
  38. int main() {
  39. std::cout << Problem::indexB(1, 2, 3) << "\n";
  40. std::cout << Problem::indexB(400, 50, 6) << "\n";
  41. std::cout << Problem::indexB(987, 65, 432) << std::endl;
  42. }
Success #stdin #stdout 0s 2988KB
stdin
Standard input is empty
stdout
001002003
400050006
987065432