2 条题解

  • 0
    @ 2024-9-29 18:02:28

    将数据看作字符

    #include <stdio.h>
    
    int main() {
        char a, b, c, d, e;
        scanf("%c%c%c%c%c", &a, &b, &c, &d, &e);
        printf("%c%c%c%c%c", e, d, c, b, a);
        return 0;
    }
    

    转为整数,利用除和模

    #include <stdio.h>
    
    int main() {
        float x;
        scanf("%f", &x);
        int n = x * 10;  // int x = 123.4 = 123;
        int a = n / 1000;
        int b = n / 100 % 10;
        int c = n / 10 % 10;
        int d = n % 10;
        printf("%d.%d%d%d", d, c, b, a);
        return 0;
    }
    
    • 0
      @ 2023-10-22 15:26:46
      #include <stdio.h>
      int main() {
          float m;
          scanf("%f", &m);
          int n = m * 10;
          int a = n / 1000, b = n / 100 % 10, c = n / 10 % 10, d = n % 10;
          float sum = (d * 10 + c * 1.0 + b * 0.1 + 0.01 * a) / 10;
          printf("%.3f", sum);
          return 0;
      }
      
      • 1

      信息

      ID
      9
      时间
      1000ms
      内存
      16MiB
      难度
      4
      标签
      递交数
      144
      已通过
      65
      上传者