C 为什么这个练习中的if不起作用?我快疯了

C 为什么这个练习中的if不起作用?我快疯了,c,C,我正在为我的代码类解决这个简单的练习,但是我尝试了所有的方法,不知道为什么这个代码不能工作 // Develop a modular structure with a function that you receive through // parameter a positive integer and returns the number quantity of this number. #include <stdio.h> #include <stdlib.h>

我正在为我的代码类解决这个简单的练习,但是我尝试了所有的方法,不知道为什么这个代码不能工作

// Develop a modular structure with a function that you receive through
// parameter a positive integer and returns the number quantity of this number.

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <math.h>

int digitos(float N){
    int i;
    for(i = 0;i<10;i++){
        printf("%f\n",N/pow(10,i));
        if((N/pow(10,i))<0.0){
            return i;
        }
    }
}


int main(){
int d ;
    d = digitos(3000);
    printf("The number of digist %d",d);

}

看起来你的数学有问题。除非N本身是负数,否则永远不会得到负数。你是说:

if ((N/pow(10, i)) < 1.0) {

这回答了你的问题吗?如果你解释一下你想用代码实现什么,什么不起作用,而不是等着我们看代码然后自己去弄清楚,那就更好了;de math是对的,但将0改为1成功了,谢谢:D