?? 06年3月29日_經(jīng)典c程序(17-20)_老古開發(fā)網(wǎng)文章.htm
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>
06年3月29日_經(jīng)典c程序(17/20)_老古開發(fā)網(wǎng)文章 </title>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta content="經(jīng)典c程序(17/20)" name="keywords">
<meta content="有關經(jīng)典c程序(17/20)的新聞和技術(shù)文章" name="description">
<LINK href="/category.css" type="text/css" rel="stylesheet">
</HEAD>
<BODY bgColor="#ffffff" leftMargin="5" topMargin="5" vLink="#0000ff">
<DIV align="center">
<table class="tableMain" width="736" border="0" align="center" >
<tr>
<td>
<table width="728" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#FDFCE8">
<tr>
<td width="290"><div align="left"><a href="http://www.zlgmcu.com/tools/LogicAnalyser/LA-logic.asp" target="_blank"><img src="/my/zlg.GIF" width="290" height="60" border="0"></a></div></td>
<td width="146"><div align="center"><a href="/GUANGGAO.HTM" target="_blank">整站廣告招商</a></div></td>
<td width="125"><div align="center"><a href="http://www.jdisplay.net" target="_blank"><img src="/my/chengqi.gif" width="140" height="60" border="0"></a></div></td>
<td width="149"><div align="right"><a href="http://www.techshine.com/peixun/peixun.asp" target="_blank"><img src="/my/techshine.gif" width="140" height="60" border="0"></a></div></td>
</tr>
<tr>
<td><a href="http://www.eflagtech.com" target="_blank"><img src="/my/yiqisite.gif" width="290" height="60" border="0"></a></td>
<td><a href="/GUANGGAO.HTM" target="_blank"><img src="/my/quanzhan.gif" width="140" height="60" border="0"></a></td>
<td> </td>
<td><div align="right"></div></td>
</tr>
</table>
</td>
</tr>
</table>
<table class="tableMain" width="736" border="0" cellpadding="0" cellspacing="0" align="center" >
<tr>
<td>
<script type="text/javascript"><!--
google_ad_client = "pub-1420557601534669";
google_ad_width = 728;
google_alternate_ad_url = "http://www.laogu.com/my/welcome.gif";
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "93c901";
google_color_url = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
<table bgcolor="#93c901" border="0" cellpadding="0" cellspacing="0" width="736">
<tbody>
<tr>
<td width="160" height="2" bgcolor="#ffffcc"><div align="left"><a href="article.aspx"><img height="70" src="MY/xinwen.gif" width="160" border="0"></a></div>
</td>
<td width="80%" height="2" bgcolor="#ffffcc"><table width="390" height="70" border="0" align="center" bgcolor="#FDFCE8">
<tr>
<td width="284"><div align="center"><a href="http://www.eetchina.com/STATIC/SITE/WEBINAR.HTM?sources=3rdpartners" target="_blank"><img src="/my/EDC_THC_banner_laogu.gif" width="400" height="60" border="0"></a></div></td>
<td width="41"><div align="right"></div></td>
</tr>
</table>
</td>
<td width="156" bgcolor="#ffffcc"><div align="right"><a href="/"><img height="70" alt="老古開發(fā)網(wǎng)首頁" src="/MY/newhome.gif" width="156" border="0"></a></div>
</td>
</tr>
</tbody>
</table>
<TABLE class="tableMain" border="0" cellPadding="3" cellSpacing="1" width="736">
<TBODY>
<TR>
<TD bgColor="#ffffff" vAlign="top" colspan="2">
<DIV align="center" class="s10">
<DIV align="center">
</DIV>
<DIV align="center"></DIV>
</DIV>
<DIV align="center">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" valign="top"
height="100%">
<tbody>
<tr>
<td align="left" height="25"><strong><br>
導航:</strong><a href="http://www.laogu.com/">老古開發(fā)網(wǎng)首頁</a>→<a href="/article.aspx">文章分類</a>→<a href=/ctg_6.htm>單片機</a>→<a href=/ctg_6_16.htm >第16頁</a>→[<font color="#004800">經(jīng)典c程序(17/20)</font>] <br>
| -<a href="searchnews.aspx" target="_blank">文章搜索</a> - <a href="articlenew.aspx" target="_blank">最新文章</a>
- | <br> <div align="center">
<h3>第1388篇:經(jīng)典c程序(17/20)</h3>
</div></td>
</tr>
<tr>
<td bgcolor="#ffffff" valign="top" class="table"> 發(fā)布時間:2006年3月28日 <br>
點擊次數(shù):143 <br> <table width="100%" border="1" cellspacing="0" bgcolor="#93c901" class=rcontent>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
詳細內(nèi)容:經(jīng)典c程序(17/20)<br> <br>
<P>題目:一球從100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在<BR> 第10次落地時,共經(jīng)過多少米?第10次反彈多高?<BR>1.程序分析:見下面注釋<BR>2.程序源代碼:<BR>main()<BR>{<BR>float sn=100.0,hn=sn/2;<BR>int n;<BR>for(n=2;n<=10;n++)<BR> {<BR> sn=sn+2*hn;/*第n次落地時共經(jīng)過的米數(shù)*/<BR> hn=hn/2; /*第n次反跳高度*/<BR> }<BR>printf("the total of road is %f\n",sn);<BR>printf("the tenth is %f meter\n",hn);<BR>}</P>
<P>題目:一個數(shù)如果恰好等于它的因子之和,這個數(shù)就稱為“完數(shù)”。例如6=1+2+3.編程<BR> 找出1000以內(nèi)的所有完數(shù)。<BR>1. 程序分析:請參照程序<--上頁程序14. <BR>2.程序源代碼:<BR>main()<BR>{<BR>static int k[10];<BR>int i,j,n,s;<BR>for(j=2;j<1000;j++)<BR> {<BR> n=-1;<BR> s=j;<BR> for(i=1;i<J;I++)<BR> {<BR> if((j%i)==0)<BR> { n++;<BR> s=s-i;<BR> k[n]=i;<BR> }<BR> }<BR> if(s==0)<BR> {<BR> printf("%d is a wanshu",j);<BR> for(i=0;i<N;I++)<BR> printf("%d,",k[i]);<BR> printf("%d\n",k[n]);<BR> }<BR>}<BR>}</P>
<P>
<TABLE cellSpacing=0 cellPadding=0 width="94%" align=center border=0>
<TBODY>
<TR>
<TD><FONT color=#000000>題目:求s=a+aa+aaa+aaaa+aa...a的值,其中a是一個數(shù)字。例如2+22+222+2222+22222(此時<BR> 共有5個數(shù)相加),幾個數(shù)相加有鍵盤控制。<BR>1.程序分析:關鍵是計算出每一項的值。<BR>2.程序源代碼:<BR>main()<BR>{<BR> int a,n,count=1;<BR> long int sn=0,tn=0;<BR> printf("please input a and n\n");<BR> scanf("%d,%d",&a,&n);<BR> printf("a=%d,n=%d\n",a,n);<BR> while(count<=n)<BR> {<BR> tn=tn+a;<BR> sn=sn+tn;<BR> a=a*10;<BR> ++count;<BR> }<BR>printf("a+aa+...=%ld\n",sn);<BR>}<BR></FONT></TD></TR></TBODY></TABLE></P>
<P>題目:輸入一行字符,分別統(tǒng)計出其中英文字母、空格、數(shù)字和其它字符的個數(shù)。<BR>1.程序分析:利用while語句,條件為輸入的字符不為''\n''.<BR> <BR>2.程序源代碼:<BR>#i nclude "stdio.h"<BR>main()<BR>{char c;<BR> int letters=0,space=0,digit=0,others=0;<BR> printf("please input some characters\n");<BR> while((c=getchar())!=''\n'')<BR> {<BR> if(c>=''a''&&c<=''z''||c>=''A''&&c<=''Z'')<BR> letters++;<BR> else if(c=='' '')<BR> space++;<BR> else if(c>=''0''&&c<=''9'')<BR> digit++;<BR> else<BR> others++;<BR>}<BR>printf("all in all:char=%d space=%d digit=%d others=%d\n",letters,<BR>space,digit,others);<BR>}</P>
<P>題目:輸入兩個正整數(shù)m和n,求其最大公約數(shù)和最小公倍數(shù)。<BR>1.程序分析:利用輾除法。 </P>
<P>2.程序源代碼:<BR>main()<BR>{<BR> int a,b,num1,num2,temp;<BR> printf("please input two numbers:\n");<BR> scanf("%d,%d",&num1,&num2);<BR> if(num1<NUM2) <br *交換兩個數(shù),使大數(shù)放在num1上*> { temp=num1;<BR> num1=num2; <BR> num2=temp;<BR> }<BR>a=num1;b=num2;<BR>while(b!=0)/*利用輾除法,直到b為0為止*/<BR> {<BR> temp=a%b;<BR> a=b;<BR> b=temp;<BR> }<BR>printf("gongyueshu:%d\n",a);<BR>printf("gongbeishu:%d\n",num1*num2/a);<BR>}<BR></P> <div align="left">
<p><br>
</p>
<p><font color="#ff0000">歡迎進入<a href="/laogubbs/" _target=_blank>老古論壇</a>對經(jīng)典c程序(17/20)進行討論<br>
</font> </p>
</div>
<br> </td>
<tr>
<td bgcolor="#ffffff" valign="top" class="table"> </td>
<tr>
<td bgcolor="#ffffff" valign="top" class="table"> </td>
<TR>
<TD >上一個:<a href=/wz_1389.htm >這18條背下來沒人敢和你忽悠CPU</a></TD>
</TR>
<TR>
<TD >下一個:<a href=/wz_1387.htm >經(jīng)典c程序(16/20)</a></TD>
</TR>
<td bgcolor="#ffffff" valign="top" class="date"> </td>
</tr>
</table>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
<div align="center"><A href="http://www.laogu.com/">老古開發(fā)網(wǎng)</A>版權(quán)所有 2005年11月 asp.Net
設計:<a href="/">老古</a>,<br>
2006-3-29 15:53:59 頁面緩存:否
375毫秒
</div>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -