|
发表于 2004-6-13 17:41:06
|
显示全部楼层
我乱写了一个,好像能够工作
[code:1]
#include <stdio.h>
#include <stdlib.h>
int
main(void) {
float f = 7.33425324;
char temp[20];
int i, j;
snprintf(temp, 20, "%f", f);
printf("%s\n", temp);
i = 0;
while (temp[i] != '.') {
i ++;
}
j = i;
while (temp[j] != '\0') {
j ++;
}
j --;
while (temp[j] == '0') {
j --;
}
printf("%d\n", j-i);
return 0;
}
[/code:1] |
|