📄 subject_37120.htm
字号:
<p>
序号:37120 发表者:SoftHt 发表日期:2003-04-22 09:18:54
<br>主题:求助,一个简单的问题?
<br>内容: 这个例子是输入是10个数,求最大数,可是我现在想求一下最大数的下标,条件还必须是用一个for循环做,我应该怎么改?<BR><BR>#include <iostream.h><BR><BR>const int max = 10;<BR><BR>int main(void)<BR>{<BR> int num[max];<BR> int maxnum = num[0];<BR><BR> for (int i=0; i<max; i++)<BR> {<BR> cout << "Input Number: ";<BR> cin >> num[i];<BR> <BR> if (num[i] > maxnum)<BR> {<BR> maxnum = num[i];<BR> }<BR> }<BR> cout << "i =" << i << endl;<BR> cout << "max = " << maxnum << endl;<BR> <BR> return 0;<BR>}
<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>回复者:neilgan 回复日期:2003-04-22 09:37:41
<br>内容:#include <iostream.h><BR><BR>const int max = 10;<BR><BR>int main(void)<BR>{<BR> int num[max];<BR> int maxnum = num[0];<BR> int nIndex=0;<BR><BR> for (int i=0; i<max; i++)<BR> {<BR> cout << "Input Number: ";<BR> cin >> num[i];<BR> <BR> if (num[i] > maxnum)<BR> {<BR> maxnum = num[i];<BR> nIndex=i;<BR> }<BR> }<BR> cout << "i =" << i << endl;<BR> cout << "max = " << maxnum << endl << "index=" << nIndex << endl;<BR> <BR> return 0;<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>
回复者:SoftHt 回复日期:2003-04-22 09:42:14
<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 + -