提示:提问和回答别人的问题均可赢得积分
问题:求百分比?
有两个整数怎么求他们两个的百分比,小数点第二位四舍五入,如(13.75---》13.8%)
我现在急着用
却不会写
那位大侠帮我下个啊
谢谢
提问时间:
2006-10-20 10:14:59 回答次数:
(8) 提问人:
软界网友 我来回答
回答(1)
int n=3;
int b= 7;
string strbfb = ((float)n/(float)b).ToString("0.00") + "%";
回答(2)
string strbfb = ((float)n/(float)b).ToString("0.00") + "%";
回答(3)
Dim s As Double = 0.123
Dim s2 As Double = 0.1001
Dim d As Double = s / s2
MsgBox(Math.Round(d, 4) * 100.ToString & "%")
回答(4)
更简单的
MsgBox(d.ToString("P"))
回答(5)
int a=8;
int b= 9;
string strbfb = ((float)a/(float)b *100).ToString("0.00") + "%";
回答(6)
int a=4;
int b= 3;
string strbfb = ((float)a/(float)b *100).ToString("f1") + "%";
回答(7)
MsgBox((a/b).ToString("P"))