📄 subject_17351.htm
字号:
<p>
序号:17351 发表者:口木子 发表日期:2002-10-10 17:00:16
<br>主题:假如有CString str="1,2...100",怎样将里面的整数分离出来,并保存在int str[100]。
<br>内容:假如有CString str="1,2...100",怎样将里面的整数分离出来,并保存在int str[100]。
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:CDMA2000 回复日期:2002-10-10 17:05:51
<br>内容:如果你的字符里有“,”<BR>那么就利用“,”来取得每个“,”前的字符串,<BR>然后将得到的字符串转换为int放入数组中<BR>接着将原来的str前的已取出的子串(包括“,”)截去<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-10-10 17:14:50
<br>内容:int iCurrent;<BR>int iNext;<BR><BR>CString str="1,2,....100";<BR>CString strTemp;<BR>for(int i=0,iCurrent=0;;i++)<BR>{<BR> <BR> iNext=str.Find(',',iCurrent);<BR> if(iNext==-1)//最后一个<BR> {<BR> <BR> strTemp=str.Mid(iCurrent);<BR> istr[i]=atoi(strTemp);<BR> break;<BR> } <BR><BR> strTemp=str.Mid(iCurrent,iNext-iCurrent);<BR> istr[i]=atoi(strTemp);<BR> iCurrent=iNext+1;<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>
回复者:TopLevel 回复日期:2002-10-10 17:15:16
<br>内容:CString str="1,2,...100";<BR>Int strInt[100];<BR><BR>//求数字个数函数。<BR>int Sum(CString str, char cDiv)<BR>{<BR> int iNum = 0;<BR> for( int i = 0; i < str.GetLength(); i++)<BR> {<BR> if ( str.GetAt(i) == cDiv )<BR> {<BR> iNum++;<BR> }<BR> }<BR> <BR> iNum++;<BR> <BR> return iNum;<BR>}<BR><BR>For( int I = 0; I < 100; I++)<BR>{<BR> int iLength = str. GetLength();<BR> Int iPos = Str. ReverseFind(‘,’)<BR> Cstring strTemp = str.Right( iLength – iPos – 1 );<BR> Str = str.Left( iPos + 1 );<BR> StrInt[100-I-1] = atoi( strTemp );<BR>}<BR><BR>2002-10-10 17:42:23
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -