📄 subject_16254.htm
字号:
<p>
序号:16254 发表者:boss 发表日期:2002-09-26 17:18:41
<br>主题:有谁会做这到题?
<br>内容:写一个程序:要求用户输入一个浮点数(float),程序将其转换成中文金额并在屏幕上输出。
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:天地 回复日期:2002-09-26 17:39:23
<br>内容:#include <iostream.h><BR>void main()<BR>{<BR> float num,second;<BR> int yuan,jiao,fen;<BR> cout<<"input a float number"<<endl;<BR> cin>>num;<BR> cout<<"这是 "<<(int)num<<"元";<BR> second=num-(int)num;<BR> jiao=(int)(second*10);<BR> fen=(int)((second*10-jiao)*10);<BR> cout<<jiao<<"角"<<fen<<"分"<<endl;<BR>}<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:天花乱追 回复日期:2002-09-26 18:19:09
<br>内容:他是要把数值转换成大写的汉字,比如5000000.000000-〉五百万整:))<BR>有空我再时时 @_@
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:凯凯 回复日期:2002-09-27 10:36:43
<br>内容:有这栏的源码你可以去找找。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:boss 回复日期:2002-09-27 10:46:12
<br>内容:我没找到,你能找到吗?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:凯凯 回复日期:2002-09-27 12:13:35
<br>内容:我只找到一个VB的源码,你把它用VC实现就可以了,很简单的。<BR><BR><BR><BR> 一个Form<BR> 一个TextBox<BR> 一个Label<BR><BR> 这个修订後的程式是当使用者在TextBox中输入只包含 0~9 的数值後,在Label中就可<BR> 看见被转换後的中文字,例如:1560890 转成 "壹佰伍拾陆万零捌佰玖拾"。程式限制<BR> 为不可输入超过16个数字。<BR><BR> 请建立一个新专案,并在表单中放入上述物件,再把以下程式码复制到表单的程式<BR> 码视窗,最後按下F5来执行。<BR><BR> Private Sub Form_Load()<BR> Text1.MaxLength = 16<BR> Text1.Text = ""<BR> Label1.Caption = ""<BR> Label1.AutoSize = True<BR> Label1.BorderStyle = 1<BR> End Sub<BR><BR> Private Sub Text1_Change()<BR> Label1.Caption = CChinese(Text1.Text)<BR> End Sub<BR><BR> Private Function CChinese(StrEng As String) As String<BR> If Not IsNumeric(StrEng) Or StrEng Like "*.*" Or StrEng Like "*-*" Then<BR> If Trim(StrEng) <> "" Then MsgBox "无效的数字"<BR> CChinese = "": Exit Function<BR> End If<BR> Dim intLen As Integer, intCounter As Integer<BR> Dim strCh As String, strTempCh As String<BR> Dim strSeqCh1 As String, strSeqCh2 As String<BR> Dim strEng2Ch As String<BR> strEng2Ch = "零壹贰叁肆伍陆柒捌玖"<BR> strSeqCh1 = " 拾佰仟 拾佰仟 拾佰仟 拾佰仟"<BR> strSeqCh2 = " 万亿兆"<BR> StrEng = CStr(CDec(StrEng))<BR> intLen = Len(StrEng)<BR> For intCounter = 1 To intLen<BR> strTempCh = Mid(strEng2Ch, Val(Mid(StrEng, intCounter, 1)) + 1, 1)<BR> If strTempCh = "零" And intLen <> 1 Then<BR> If Mid(StrEng, intCounter + 1, 1) = "0" Or (intLen - intCounter + 1) Mod 4 = 1 Then<BR> strTempCh = ""<BR> End If<BR> Else<BR> strTempCh = strTempCh & Trim(Mid(strSeqCh1, intLen - intCounter + 1, 1))<BR> End If<BR> If (intLen - intCounter + 1) Mod 4 = 1 Then<BR> strTempCh = strTempCh & Mid(strSeqCh2, (intLen - intCounter + 1) \ 4 + 1, 1)<BR> If intCounter > 3 Then<BR> If Mid(StrEng, intCounter - 3, 4) = "0000" Then strTempCh = Left(strTempCh, Len(strTempCh) - 1)<BR> End If<BR> End If<BR> strCh = strCh & Trim(strTempCh)<BR> Next<BR> CChinese = strCh<BR> End Function<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:boss 回复日期:2002-09-28 08:44:40
<br>内容:谢谢你凯凯!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:凯凯 回复日期:2002-09-28 09:48:15
<br>内容:别忘了给分。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -