⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 经典c程序100例==31--40.htm

📁 C经典算法包含了C经典算法100个程序,资料中的内容是以网页形式保存的.很好的东西
💻 HTM
📖 第 1 页 / 共 3 页
字号:
                              color++)<BR> { 
                              <BR> textbackground(color);/*设置文本的背景颜色*/<BR> cprintf("This 
                              is color %d\r\n", color);<BR> cprintf("Press any 
                              key to 
                              continue\r\n");<BR> getch();/*输入字符看不见*/<BR> }<BR>}<BR>==============================================================<BR><FONT 
                              color=#990000>【程序33】</FONT><BR>题目:学习gotoxy()与clrscr()函数   <BR>1.程序分析:<BR>2.程序源代码:<BR>#include 
                              &lt;conio.h&gt;<BR>void 
                              main(void)<BR>{<BR>clrscr();/*清屏函数*/<BR>textbackground(2);<BR>gotoxy(1, 
                              5);/*定位函数*/<BR>cprintf("Output at row 5 column 
                              1\n");<BR>textbackground(3);<BR>gotoxy(20, 
                              10);<BR>cprintf("Output at row 10 column 
                              20\n");<BR>}<BR>==============================================================<BR><FONT 
                              color=#990000>【程序34】</FONT><BR>题目:练习函数调用<BR>1. 
                              程序分析: <BR>2.程序源代码:<BR>#include 
                              &lt;stdio.h&gt;<BR>void 
                              hello_world(void)<BR>{<BR>printf("Hello, 
                              world!\n");<BR>}<BR>void 
                              three_hellos(void)<BR>{<BR>int counter;<BR>for 
                              (counter = 1; counter &lt;= 3; 
                              counter++)<BR>hello_world();/*调用此函数*/<BR>}<BR>void 
                              main(void)<BR>{<BR>three_hellos();/*调用此函数*/<BR>}<BR>==============================================================<BR><FONT 
                              color=#990000>【程序35】</FONT><BR>题目:文本颜色设置<BR>1.程序分析:<BR>2.程序源代码:<BR>#include 
                              &lt;conio.h&gt;<BR>void main(void)<BR>{<BR>int 
                              color;<BR>for (color = 1; color &lt; 16; 
                              color++)<BR> {<BR> textcolor(color);/*设置文本颜色*/<BR> cprintf("This 
                              is color %d\r\n", color);<BR> }<BR>textcolor(128 + 
                              15);<BR>cprintf("This is 
                              blinking\r\n");<BR>}<BR>==============================================================<BR><FONT 
                              color=#990000>【程序36】</FONT><BR>题目:求100之内的素数   <BR>1.程序分析:<BR>2.程序源代码:<BR>#include 
                              &lt;stdio.h&gt;<BR>#include "math.h"<BR>#define N 
                              101<BR>main()<BR>{<BR>int 
                              i,j,line,a[N];<BR>for(i=2;i&lt;N;i++) 
                              a[i]=i;<BR>for(i=2;i&lt;sqrt(N);i++)<BR> for(j=i+1;j&lt;N;j++)<BR> {<BR>  if(a[i]!=0&amp;&amp;a[j]!=0)<BR>  if(a[j]%a[i]==0)<BR>  a[j]=0;}<BR>printf("\n");<BR>for(i=2,line=0;i&lt;N;i++)<BR>{<BR> if(a[i]!=0)<BR> {printf("%5d",a[i]);<BR> line++;}<BR> if(line==10)<BR> {printf("\n");<BR>line=0;}<BR>}<BR>}<BR>==============================================================<BR><FONT 
                              color=#990000>【程序37】</FONT><BR>题目:对10个数进行排序<BR>1.程序分析:可以利用选择法,即从后9个比较过程中,选择一个最小的与第一个元素交换,<BR>      下次类推,即用第二个元素与后8个进行比较,并进行交换。 
                                     <BR>2.程序源代码:<BR>#define N 
                              10<BR>main()<BR>{int i,j,min,tem,a[N];<BR>/*input 
                              data*/<BR>printf("please input ten 
                              num:\n");<BR>for(i=0;i&lt;N;i++)<BR>{<BR>printf("a[%d]=",i);<BR>scanf("%d",&amp;a[i]);}<BR>printf("\n");<BR>for(i=0;i&lt;N;i++)<BR>printf("%5d",a[i]);<BR>printf("\n");<BR>/*sort 
                              ten 
                              num*/<BR>for(i=0;i&lt;N-1;i++)<BR>{min=i;<BR>for(j=i+1;j&lt;N;j++)<BR>if(a[min]&gt;a[j]) 
                              min=j;<BR>tem=a[i];<BR>a[i]=a[min];<BR>a[min]=tem;<BR>}<BR>/*output 
                              data*/<BR>printf("After sorted 
                              \n");<BR>for(i=0;i&lt;N;i++)<BR>printf("%5d",a[i]);<BR>}<BR>==============================================================<BR><FONT 
                              color=#990000>【程序38】</FONT><BR>题目:求一个3*3矩阵对角线元素之和 
                              <BR>1.程序分析:利用双重for循环控制输入二维数组,再将a[i][i]累加后输出。<BR>2.程序源代码:<BR>main()<BR>{<BR>float 
                              a[3][3],sum=0;<BR>int i,j;<BR>printf("please input 
                              rectangle 
                              element:\n");<BR>for(i=0;i&lt;3;i++)<BR> for(j=0;j&lt;3;j++)<BR> scanf("%f",&amp;a[i][j]);<BR>for(i=0;i&lt;3;i++)<BR> sum=sum+a[i][i];<BR>printf("duijiaoxian 
                              he is 
                              %6.2f",sum);<BR>}<BR>==============================================================<BR><FONT 
                              color=#990000>【程序39】</FONT><BR>题目:有一个已经排好序的数组。现输入一个数,要求按原来的规律将它插入数组中。<BR>1. 
                              程序分析:首先判断此数是否大于最后一个数,然后再考虑插入中间的数的情况,插入后<BR>     此元素之后的数,依次后移一个位置。 
                              <BR>2.程序源代码:<BR>main()<BR>{<BR>int 
                              a[11]={1,4,6,9,13,16,19,28,40,100};<BR>int 
                              temp1,temp2,number,end,i,j;<BR>printf("original 
                              array 
                              is:\n");<BR>for(i=0;i&lt;10;i++)<BR> printf("%5d",a[i]);<BR>printf("\n");<BR>printf("insert 
                              a new 
                              number:");<BR>scanf("%d",&amp;number);<BR>end=a[9];<BR>if(number&gt;end)<BR> a[10]=number;<BR>else<BR> {for(i=0;i&lt;10;i++)<BR>  { 
                              if(a[i]&gt;number)<BR>   {temp1=a[i];<BR>    a[i]=number;<BR>   for(j=i+1;j&lt;11;j++)<BR>   {temp2=a[j];<BR>    a[j]=temp1;<BR>    temp1=temp2;<BR>   }<BR>   break;<BR>   }<BR>  }<BR>}<BR>for(i=0;i&lt;11;i++)<BR> printf("%6d",a[i]);<BR>}<BR>==============================================================<BR><FONT 
                              color=#990000>【程序40】</FONT><BR>题目:将一个数组逆序输出。<BR>1.程序分析:用第一个与最后一个交换。<BR>2.程序源代码:<BR>#define 
                              N 5<BR>main()<BR>{ int 
                              a[N]={9,6,5,4,1},i,temp;<BR> printf("\n original 
                              array:\n");<BR> for(i=0;i&lt;N;i++)<BR> printf("%4d",a[i]);<BR> for(i=0;i&lt;N/2;i++)<BR> {temp=a[i];<BR>  a[i]=a[N-i-1];<BR>  a[N-i-1]=temp;<BR> }<BR>printf("\n 
                              sorted 
                              array:\n");<BR>for(i=0;i&lt;N;i++)<BR> printf("%4d",a[i]);<BR>}</P>
                              <P></P></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
                  <TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=0 
                  width=650 align=center bgColor=#d7ebff border=0>
                    <TBODY>
                    <TR vAlign=center align=middle bgColor=#3986ef>
                      <TD id=notice vAlign=center align=left colSpan=2 
                        height=25>&nbsp;&nbsp;<FONT 
                        color=#ffffff><B>[</B>来源<B>]</B>: 不详 &nbsp;&nbsp;&nbsp; 
                        <B>[</B>编辑<B>]</B>: <FONT color=#ffffff>beck 
                        </FONT>&nbsp;&nbsp;&nbsp;<B>[</B>加入时间<B>]</B>:2002-8-11 
                        </FONT></TD></TR></TBODY></TABLE><BR><BR>
                  <TABLE width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD>
                        <LI><FONT color=#0772b1>上篇文章</FONT>:<A 
                        href="http://www.vcok.com/class/list.asp?id=205">经典c程序100例==21--30</A> 

                        <LI><FONT color=#0772b1>下篇文章</FONT>:<A 
                        href="http://www.vcok.com/class/list.asp?id=207">经典c程序100例==41--50</A> 
                        </LI></TD>
                      <TD align=right>
                        <SCRIPT language=JavaScript>
var onecount;
onecount=0;
subcat = new Array();
        
subcat[0] = new Array("C语言教程","8","35");
        
subcat[1] = new Array("C技术文章","8","36");
        
subcat[2] = new Array("C试题库","8","37");
        
subcat[3] = new Array("C程序百例","8","38");
        
subcat[4] = new Array("C函数库","8","39");
        
subcat[5] = new Array("数据结构教程","9","40");
        
subcat[6] = new Array("常用算法","9","41");
        
subcat[7] = new Array("在线测试","8","42");
        
subcat[8] = new Array("linux入门级","10","43");
        
onecount=9;

function changelocation(locationid)
    {
    document.myform.Nclassid.length = 0; 

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
                document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    
</SCRIPT>

                        <FORM name=myform action=ru_query.asp method=post>文章搜索: 
                        <SELECT size=1 name=action> <OPTION value=title 
                          selected>按文章标题搜索</OPTION> <OPTION 
                          value=writer>按文章来源搜索</OPTION> <OPTION 
                          value=content>按文章内容搜索</OPTION> <OPTION 
                          value=Nkey>按照关键词搜索</OPTION></SELECT> <SELECT 
                        onchange=changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value) 
                        size=1 name=classid> <OPTION value="" 
                          selected>请指定范围</OPTION> <OPTION value=8>C语言教室</OPTION> 
                          <OPTION value=9>数据结构</OPTION> <OPTION 
                          value=10>Linux初探</OPTION></SELECT> <SELECT 
                          name=Nclassid> <OPTION value="" 
                          selected>请指定范围</OPTION> <OPTION value=8>C语言教程</OPTION> 
                          <OPTION value=8>C技术文章</OPTION> <OPTION 
                          value=8>C试题库</OPTION> <OPTION value=8>C程序百例</OPTION> 
                          <OPTION value=8>C函数库</OPTION> <OPTION 
                          value=9>数据结构教程</OPTION> <OPTION value=9>常用算法</OPTION> 
                          <OPTION value=8>在线测试</OPTION> <OPTION 
                          value=10>linux入门级</OPTION></SELECT> <INPUT maxLength=50 
                        size=10 value=输入关键字 name=keyword> <INPUT type=submit value=搜索 name=Submit> 
                    </FORM></TD></TR></TBODY></TABLE></TD></TR>
              <TR>
                <TD width="50%" bgColor=#e6e6e6>□- C程序百例热点文章</TD>
                <TD width="50%" bgColor=#e6e6e6>□- 相关文章</TD></TR>
              <TR>
                <TD vAlign=top width="50%" bgColor=#ffffff>1.<A 
                  title=经典c程序100例==91--100 
                  href="http://www.vcok.com/class/list.asp?id=212" target=_top> 
                  经典c程序100例==91--100 </A>[阅读:<FONT 
                  color=red>54281</FONT>]<BR>2.<A title=经典c程序100例==1--10 
                  href="http://www.vcok.com/class/list.asp?id=203" target=_top> 
                  经典c程序100例==1--10 </A>[阅读:<FONT color=red>35286</FONT>]<BR>3.<A 
                  title=经典c程序100例==51--60 
                  href="http://www.vcok.com/class/list.asp?id=208" target=_top> 
                  经典c程序100例==51--60 </A>[阅读:<FONT 
                  color=red>26795</FONT>]<BR>4.<A title="经典c程序100例==11--20 " 
                  href="http://www.vcok.com/class/list.asp?id=204" target=_top> 
                  经典c程序100例==11--20 </A>[阅读:<FONT 
                  color=red>25227</FONT>]<BR>5.<A title="经典c程序100例==81--90 " 
                  href="http://www.vcok.com/class/list.asp?id=211" target=_top> 
                  经典c程序100例==81--90 </A>[阅读:<FONT color=red>23814</FONT>]<BR></TD>
                <TD vAlign=top width="50%" bgColor=#ffffff><A 
                  href="http://www.vcok.com/class/list.asp?id=212">经典c程序100例==91--100</A><BR><A 
                  href="http://www.vcok.com/class/list.asp?id=211">经典c程序100例==81--90 
                  </A><BR><A 
                  href="http://www.vcok.com/class/list.asp?id=210">经典c程序100例==71--80</A><BR><A 
                  href="http://www.vcok.com/class/list.asp?id=209">经典c程序100例==61--70</A><BR><A 
                  href="http://www.vcok.com/class/list.asp?id=208">经典c程序100例==51--60</A><BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
      <DIV></DIV>
      <TABLE width=778 bgColor=#ffffff border=0>
        <TBODY>
        <TR bgColor=#ffffff>
          <TD colSpan=3></TD></TR>
        <TR vAlign=baseline>
          <TD colSpan=3>
            <HR noShade SIZE=1>
          </TD></TR>
        <TR>
          <TD width="7%">&nbsp;</TD>
          <TD width="87%">
            <DIV align=center>唯C世界|<FONT 
            face="Arial, Helvetica, sans-serif">http://wWw.VcOk.Com</FONT>   <FONT 
            face="Arial, Helvetica, sans-serif">Ver 1.00 Design By <FONT 
            face="Verdana, Arial, Helvetica, sans-serif"><B><FONT 
            color=#ff0000><A href="http://www.vcok.com/"><FONT 
            color=#ff0009>VcOk.com</FONT></A></FONT></B></FONT></FONT></FONT></DIV></TD>
          <TD width="6%">&nbsp;</TD></TR>
        <TR>
          <TD width="7%">&nbsp;</TD>
          <TD width="87%">
            <DIV align=center><FONT 
            face="Arial, Helvetica, sans-serif">CopyRight <FONT 
            color=#ff0000>&copy;</FONT> .:.:.:2002-2008 AT Tie Ling Liaoning 
            China:.:.:.</FONT></DIV></TD>
          <TD width="6%">&nbsp;</TD></TR>
        <TR>
          <TD width="7%">&nbsp;</TD>
          <TD align=middle width="87%">&nbsp;&nbsp;&nbsp;&nbsp;辽宁省铁岭师专微机室 
            <U>杨志锋</U> 数学系 <U>杜博</U> &nbsp;&nbsp;&nbsp;&nbsp;</TD>
          <TD width="6%">&nbsp;</TD></TR></TBODY></TABLE></TR></TBODY></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -