www.sllg.net > 将一个浮点数转化成字符串的程序

将一个浮点数转化成字符串的程序

char * float2str(float val, int precision, char *buf) { char *cur, *end; sprintf(buf, "%.6f", val); if (precision < 6) { cur = buf + strlen(buf) - 1; end = cur - 6 + precision; while ((cur > end) && (*cur == '0')) { *cur = '\0'...

这个的话是可以的。#include#define uchar unsigned charuchar code table[]="abcd12.5";main(){flat a;uchar i;a=(float)table[4]*10.0+(float)table[5]+(float)table[7]/10;while(1);}

#include main() {int n,i=0,j; char s[80]; scanf("%d",&n); while(n) {s[i]=n%10; n=n/10; i++; } for(j=i-1;j>=0;j--) printf("%d",s[j]); printf("\n"); }

#include#define LEN 30int main(){ void toString(__int64 x,char *p); char str[LEN]; __int64 x; printf("请输入要转换的整数: "); scanf("%I64d",&x); toString(x,str); printf("转换成字符串: %s\n",str); return 0;}void toString(__int64...

double v = double.Parse(Console.ReadLine()); Console.WriteLine((int)v); Console.WriteLine(v.ToString()); 或者 double v = Convert.ToDouble(Console.ReadLine()); Console.WriteLine(Convert.ToInt32(v)); Console.WriteLine(Convert.ToS...

#include #include void main(){ double num; char str[100]; gets(str); num=atof(str); printf("%g\n",num);}

#include#includedouble sTof(char *s){ double s1,s2; int i=0; s1 = 0; while(s[i]!='.'&&s[i] != 0){ s1 = s1*10 +s[i] - '0'; i +=1; } if(s[i] == 0) return s1; i += 1; double k = 0.1; s2 = 0; while(s[i] != 0){ s2 = s2 + k*(s[i] - '...

#include void main(){ char str_float[30]; double fNum=-123.45678 ; sprintf( str_float, "%f", fNum ); puts(str_float );}

给你个思路,取余1000等于几就叫几千,白大写的1到9放在数组里,还有很多情况需要判断一下,而且你没有写明要用什么语言写埃。。。还是说你只要程序

网站地图

All rights reserved Powered by www.sllg.net

copyright ©right 2010-2021。
www.sllg.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com