fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. int num1, num2;
  6. printf("1つ目: ");
  7. scanf("%d", &num1);
  8. printf("2つ目: ");
  9. scanf("%d", &num2);
  10.  
  11.  
  12. // num2の桁数を求める
  13. int temp = num2, digits = 0;
  14. if (temp == 0) {
  15. digits = 1;
  16. } else {
  17. while (temp != 0) {
  18. temp /= 10;
  19. digits++;
  20. }
  21. }
  22.  
  23. // num1を10^digits倍してnum2を加える
  24. int result = num1 * (int)pow(10, digits) + num2;
  25.  
  26. printf("%d", result);
  27. return 0;
  28. }
  29.  
  30.  
Success #stdin #stdout 0s 5320KB
stdin
1 4
stdout
1つ目: 2つ目: 14