如何用两位小数转换六位数? [英] How to convert a six digit number with two decimal?

查看:136
本文介绍了如何用两位小数转换六位数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有两个号码,如(800022和900002)。我想将它转换成两个十进制像(8.2.2和9.0.2),我希望在第一个数字之后,最后一个和最后一个数字之前放小数,那么任何人都可以帮我解决这个问题吗? />


谢谢,

Hello,
I have two numbers like(800022 and 900002). I want to convert it with two decimal like (8.2.2 and 9.0.2) that is I want to put decimal after first digit, before last and before last second digit, so can any one help me to solve this issue ?

Thanks,

推荐答案

试试这段代码。记住这只是逻辑不必要的优化代码。



Try this code. Remember this just the logic not necessary the optimized code.

int a = 800022;
char []c=a.ToString().Reverse().ToArray();
string s = c[5] + "." +c[1]+ "."+ c[0];


试试这段代码:

Try this code:
int number = 900002;
string n = number.ToString();
n = n[0] + "." + n[n.Length - 2] + "." + n[n.Length - 1];



代码将以任意数量的数字工作。


This code will work in any number of digits.


这篇关于如何用两位小数转换六位数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆