整数位数

#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main() {
    double n;
    int k;
    int res = 0;
    scanf("%lf", &n);
    if (n > -1 && n < 1) {
        cout << 0 << endl;
        return 0;
    }
    k = floor(abs(n));
    while (k != 0) {
        res++;
        k = k/10;
    }
    cout << res << endl;
    return 0;
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2021-10-30
  • 2022-12-23
  • 2021-09-24
猜你喜欢
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2021-08-13
  • 2022-01-25
  • 2022-12-23
相关资源
相似解决方案