源代碼如下:
#include <stdio.h> #include <conio.h> double tail(double x, int n) { int m; while(x>=1) { m++; x=x/10; } while(x<0.1) { m--; x=x*10; } *n=m; return x; } int main() { double x,m; int n, x_sign=1; do { printf("please input the x:"); scanf("%lf,&x"); }while(0=x); if(x<0) { x_sign=-1; x=-x;} m=tail(x, &n); m=x_sign*m; printf("%lfe%d", m,n); getch(); return 0; }
|