📄 subject_26759.htm
字号:
<p>
序号:26759 发表者:heavenkiller 发表日期:2003-01-04 20:44:10
<br>主题:救命啊!MY GOD!
<br>内容://这是一个表的维护的问题,在一个按从小到大的顺序排列的数组中,插入一个数OTHER<BR>//程序将这个数与数组中的数比较之后,将它按从小到大的顺序插入数组中<BR>#include <iostream.h><BR>const int MAX=100;<BR>int queen(int [],int,int);<BR><BR>//relization of function<BR><BR>int queen(int vol[],int n,int another)<BR>{<BR> int i=0,k;<BR> while (another>vol[i])<BR> {i++;}<BR><BR> for (k=n;k=i;k--)<BR> {<BR> vol[k]=vol[k-1];<BR> }<BR> vol[k]=another;<BR> cout <<"notice:";<BR> cout <<vol[k]<<endl;<BR> return (n+1);<BR>}<BR><BR>main ()<BR>{<BR> int num[MAX]={109,122,136,144,157,172,178,185,192,9999};<BR> int m=10,other,i,n,z;<BR><BR> cout <<"*********************************************"<<endl;<BR> cout <<"the first:"<<num[0]<<endl;<BR><BR> for (i=0;i<m;i++)<BR> {<BR> cout <<num[i]<<endl;<BR> }<BR><BR><BR><BR><BR><BR> cout <<"please enter the number you want to insert:";<BR> cin >>other;<BR><BR> n=queen(num,m,other);<BR><BR><BR> cout <<"*********************************************"<<endl;<BR> cout <<"the first:"<<num[0]<<endl;<BR><BR> for (i=0;i<m;i++)<BR> {<BR> cout <<num[i]<<endl;<BR> }<BR> cout <<n<<endl;<BR> cin >>z;<BR> return 0;<BR>}<BR><BR><BR>但是我在运行这个程序的时候系统出现崩溃,我查了半天也不知是为什么,只有把它发到网上求助各位了!<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>回复者:tjhe 回复日期:2003-01-04 21:08:29
<br>内容:int queen(int vol[],int n,int another)<BR>{<BR> int i=0,k;<BR> while (another>vol[i])<BR> {i++;}<BR><BR> for (k=n;k=i;k--) //for (k=n;k>i;k--)<BR> {<BR> vol[k]=vol[k-1];<BR> }<BR> vol[k]=another;<BR> cout <<"notice:";<BR> cout <<vol[k]<<endl;<BR> return (n+1);<BR>}<BR><BR>main()最后:<BR> for (i=0;i<m;i++) //for (i=0;i<n;i++)<BR> {<BR> cout <<num[i]<<endl;<BR> }<BR> cout <<n<<endl;<BR> cin >>z;<BR> return 0;<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 + -