?? 經(jīng)典c程序100例==71--80.htm
字號:
==>%d\n",ptr->data);<BR> ptr=ptr->next;<BR>}}<BR>==============================================================<BR><FONT
color=#990000>【程序74】</FONT><BR>題目:連接兩個鏈表。<BR>1.程序分析:<BR>2.程序源代碼:<BR>#include
"stdlib.h"<BR>#include "stdio.h"<BR>struct
list<BR>{ int data;<BR>struct list
*next;<BR>};<BR>typedef struct list
node;<BR>typedef node *link;<BR>link
delete_node(link pointer,link tmp)<BR>{if
(tmp==NULL) /*delete first node*/<BR> return
pointer->next;<BR>else<BR>{
if(tmp->next->next==NULL)/*delete last
node*/<BR> tmp->next=NULL;<BR> else /*delete
the other
node*/<BR> tmp->next=tmp->next->next;<BR> return
pointer;<BR>}<BR>}<BR>void selection_sort(link
pointer,int num)<BR>{ link tmp,btmp;<BR> int
i,min;<BR> for(i=0;i<num;i++)<BR> {<BR> tmp=pointer;<BR> min=tmp->data;<BR> btmp=NULL;<BR> while(tmp->next)<BR> {
if(min>tmp->next->data)<BR> {min=tmp->next->data;<BR> btmp=tmp;<BR> }<BR> tmp=tmp->next;<BR> }<BR>printf("\40:
%d\n",min);<BR>pointer=delete_node(pointer,btmp);<BR>}<BR>}<BR>link
create_list(int array[],int num)<BR>{ link
tmp1,tmp2,pointer;<BR>int
i;<BR>pointer=(link)malloc(sizeof(node));<BR>pointer->data=array[0];<BR>tmp1=pointer;<BR>for(i=1;i<num;i++)<BR>{
tmp2=(link)malloc(sizeof(node));<BR> tmp2->next=NULL;<BR> tmp2->data=array[i];<BR> tmp1->next=tmp2;<BR> tmp1=tmp1->next;<BR>}<BR>return
pointer;<BR>}<BR>link concatenate(link
pointer1,link pointer2)<BR>{ link
tmp;<BR>tmp=pointer1;<BR>while(tmp->next)<BR> tmp=tmp->next;<BR>tmp->next=pointer2;<BR>return
pointer1;<BR>}<BR>void main(void)<BR>{ int
arr1[]={3,12,8,9,11};<BR> link
ptr;<BR> ptr=create_list(arr1,5);<BR> selection_sort(ptr,5);<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序75】</FONT><BR>題目:放松一下,算一道簡單的題目。<BR>1.程序分析:<BR>2.程序源代碼:<BR>main()<BR>{<BR>int
i,n;<BR>for(i=1;i<5;i++)<BR>{
n=0;<BR> if(i!=1)<BR> n=n+1;<BR> if(i==3)<BR> n=n+1;<BR> if(i==4)<BR> n=n+1;<BR> if(i!=4)<BR> n=n+1;<BR> if(n==3)<BR> printf("zhu
hao shi de
shi:%c",64+i);<BR> }<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序76】</FONT><BR>題目:編寫一個函數(shù),輸入n為偶數(shù)時,調用函數(shù)求1/2+1/4+...+1/n,當輸入n為奇數(shù)時,調用函數(shù)<BR> 1/1+1/3+...+1/n(利用指針函數(shù))<BR>1.程序分析:<BR>2.程序源代碼:<BR>main()<BR>#include
"stdio.h"<BR>main()<BR>{<BR>float
peven(),podd(),dcall();<BR>float sum;<BR>int
n;<BR>while
(1)<BR>{<BR> scanf("%d",&n);<BR> if(n>1)<BR> break;<BR>}<BR>if(n%2==0)<BR>{<BR> printf("Even=");<BR> sum=dcall(peven,n);<BR>}<BR>else<BR>{<BR> printf("Odd=");<BR> sum=dcall(podd,n);<BR>}<BR>printf("%f",sum);<BR>}<BR>float
peven(int n)<BR>{<BR>float s;<BR>int
i;<BR>s=1;<BR>for(i=2;i<=n;i+=2)<BR> s+=1/(float)i;<BR>return(s);<BR>}<BR>float
podd(n)<BR>int n;<BR>{<BR>float s;<BR>int
i;<BR>s=0;<BR>for(i=1;i<=n;i+=2)<BR> s+=1/(float)i;<BR>return(s);<BR>}<BR>float
dcall(fp,n)<BR>float (*fp)();<BR>int
n;<BR>{<BR>float
s;<BR>s=(*fp)(n);<BR>return(s);<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序77】</FONT><BR>題目:填空練習(指向指針的指針)<BR>1.程序分析: <BR>2.程序源代碼:<BR>main()<BR>{
char
*s[]={"man","woman","girl","boy","sister"};<BR>char
**q;<BR>int
k;<BR>for(k=0;k<5;k++)<BR>{ ;/*這里填寫什么語句*/<BR> printf("%s\n",*q);<BR>}<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序78】</FONT><BR>題目:找到年齡最大的人,并輸出。請找出程序中有什么問題。<BR>1.程序分析:<BR>2.程序源代碼:<BR>#define
N 4<BR>#include "stdio.h"<BR>static struct
man<BR>{ char name[20];<BR>int age;<BR>}
person[N]={"li",18,"wang",19,"zhang",20,"sun",22};<BR>main()<BR>{struct
man *q,*p;<BR>int i,m=0;<BR>p=person;<BR>for
(i=0;i<N;i++)<BR>{if(m<p->age)<BR> q=p++;<BR> m=q->age;}<BR>printf("%s,%d",(*q).name,(*q).age);<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序79】</FONT><BR>題目:字符串排序。<BR>1.程序分析:<BR>2.程序源代碼:<BR>main()<BR>{<BR>char
*str1[20],*str2[20],*str3[20];<BR>char
swap();<BR>printf("please input three
strings\n");<BR>scanf("%s",str1);<BR>scanf("%s",str2);<BR>scanf("%s",str3);<BR>if(strcmp(str1,str2)>0)
swap(str1,str2);<BR>if(strcmp(str1,str3)>0)
swap(str1,str3);<BR>if(strcmp(str2,str3)>0)
swap(str2,str3);<BR>printf("after being
sorted\n");<BR>printf("%s\n%s\n%s\n",str1,str2,str3);<BR>}<BR>char
swap(p1,p2)<BR>char *p1,*p2;<BR>{<BR>char
*p[20];<BR>strcpy(p,p1);strcpy(p1,p2);strcpy(p2,p);<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序80】</FONT><BR>題目:海灘上有一堆桃子,五只猴子來分。第一只猴子把這堆桃子憑據(jù)分為五份,多了一個,這只<BR> 猴子把多的一個扔入海中,拿走了一份。第二只猴子把剩下的桃子又平均分成五份,又多了<BR> 一個,它同樣把多的一個扔入海中,拿走了一份,第三、第四、第五只猴子都是這樣做的,<BR> 問海灘上原來最少有多少個桃子?<BR>1.程序分析:<BR>2.程序源代碼:<BR>main()<BR>{int
i,m,j,k,count;<BR>for(i=4;i<10000;i+=4)<BR>{
count=0;<BR>m=i;<BR>for(k=0;k<5;k++)<BR>{<BR> j=i/4*5+1;<BR> i=j;<BR> if(j%4==0)<BR> count++;<BR> else<BR> break;<BR>}<BR> i=m;<BR> if(count==4)<BR> {printf("%d\n",count);<BR> break;}<BR>}<BR>}</P>
<P></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> <FONT
color=#ffffff><B>[</B>來源<B>]</B>: beck
<B>[</B>編輯<B>]</B>: <FONT color=#ffffff>beck
</FONT> <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=209">經(jīng)典c程序100例==61--70</A>
<LI><FONT color=#0772b1>下篇文章</FONT>:<A
href="http://www.vcok.com/class/list.asp?id=211">經(jīng)典c程序100例==81--90
</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函數(shù)庫","8","39");
subcat[5] = new Array("數(shù)據(jù)結構教程","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>數(shù)據(jù)結構</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函數(shù)庫</OPTION> <OPTION
value=9>數(shù)據(jù)結構教程</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=經(jīng)典c程序100例==91--100
href="http://www.vcok.com/class/list.asp?id=212" target=_top>
經(jīng)典c程序100例==91--100 </A>[閱讀:<FONT
color=red>54281</FONT>]<BR>2.<A title=經(jīng)典c程序100例==1--10
href="http://www.vcok.com/class/list.asp?id=203" target=_top>
經(jīng)典c程序100例==1--10 </A>[閱讀:<FONT color=red>35286</FONT>]<BR>3.<A
title=經(jīng)典c程序100例==51--60
href="http://www.vcok.com/class/list.asp?id=208" target=_top>
經(jīng)典c程序100例==51--60 </A>[閱讀:<FONT
color=red>26796</FONT>]<BR>4.<A title="經(jīng)典c程序100例==11--20 "
href="http://www.vcok.com/class/list.asp?id=204" target=_top>
經(jīng)典c程序100例==11--20 </A>[閱讀:<FONT
color=red>25227</FONT>]<BR>5.<A title="經(jīng)典c程序100例==81--90 "
href="http://www.vcok.com/class/list.asp?id=211" target=_top>
經(jīng)典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">經(jīng)典c程序100例==91--100</A><BR><A
href="http://www.vcok.com/class/list.asp?id=211">經(jīng)典c程序100例==81--90
</A><BR><A
href="http://www.vcok.com/class/list.asp?id=210">經(jīng)典c程序100例==71--80</A><BR><A
href="http://www.vcok.com/class/list.asp?id=209">經(jīng)典c程序100例==61--70</A><BR><A
href="http://www.vcok.com/class/list.asp?id=208">經(jīng)典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%"> </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%"> </TD></TR>
<TR>
<TD width="7%"> </TD>
<TD width="87%">
<DIV align=center><FONT
face="Arial, Helvetica, sans-serif">CopyRight <FONT
color=#ff0000>©</FONT> .:.:.:2002-2008 AT Tie Ling Liaoning
China:.:.:.</FONT></DIV></TD>
<TD width="6%"> </TD></TR>
<TR>
<TD width="7%"> </TD>
<TD align=middle width="87%"> 遼寧省鐵嶺師專微機室
<U>楊志鋒</U> 數(shù)學系 <U>杜博</U> </TD>
<TD width="6%"> </TD></TR></TBODY></TABLE></TR></TBODY></DIV></BODY></HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -