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. // num2の桁数を求める
  12. int temp = num2, digits = 0;
  13. if (temp == 0) {
  14. digits = 1;
  15. } else {
  16. while (temp != 0) {
  17. temp /= 10;
  18. digits++;
  19. }
  20. }
  21.  
  22. // num1を10^digits倍してnum2を加える
  23. int result = num1 * (int)pow(10, digits) + num2;
  24.  
  25. printf("%d",result);
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5320KB
stdin
1  
2
stdout
1つ目: 2つ目: 12