📄 经典c程序100例==71--80.htm
字号:
ie5menu.style.visibility = "hidden";
}
function highlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "highlight";
event.srcElement.style.color = "white";
if (display_url)
window.status = event.srcElement.url;
}
}
function lowlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "";
event.srcElement.style.color = "black";
window.status = "";
}
}
function jumptoie5() {
if (event.srcElement.className == "menuitems") {
if (event.srcElement.getAttribute("target") != null)
window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
else
window.location = event.srcElement.url;
}
}
// End -->
</SCRIPT>
<SCRIPT language=JavaScript>
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</SCRIPT>
<DIV id=Layer1
style="Z-INDEX: 1; LEFT: 484px; VISIBILITY: hidden; WIDTH: 146px; POSITION: absolute; TOP: 68px; HEIGHT: 24px">
<TABLE height=24 cellSpacing=0 cellPadding=1 width="100%"
bgColor=#000000 border=0>
<TBODY>
<TR>
<TD>
<TABLE height=24 cellSpacing=0 cellPadding=0
width="100%" bgColor=#ffffe6 border=0>
<TBODY>
<TR>
<TD
class=zi>点击“保存设置”按扭可使您本次阅读的整体设置(文字、字号、背景)得以保留,下次阅读时您就不必再重新设置,以符合您的阅读习惯。</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV>
<DIV id=Layer2
style="Z-INDEX: 2; LEFT: 644px; WIDTH: 19px; POSITION: absolute; TOP: 6px; HEIGHT: 14px"> </DIV>
<TABLE cellSpacing=0 cellPadding=0 width=650 align=center>
<TBODY>
<TR vAlign=center align=left>
<TD vAlign=top width=650
background=经典c程序100例==71--80.files/titleback.png colSpan=2
height=22>
<TABLE cellSpacing=2 cellPadding=0 width="100%"
border=0>
<TBODY>
<TR>
<TD vAlign=top width=40> </TD>
<TD class=zi vAlign=center width=562><B><FONT
color=#ffffff>.:.:经典c程序100例==71--80:.:.</FONT></B></TD>
<TD class=zi vAlign=top width=18> </TD>
<TD vAlign=center width=16><A title=关闭窗口
href="javascript:window.close();"><IMG height=19
src="经典c程序100例==71--80.files/close.png" width=19
border=0></A></TD></TR></TBODY></TABLE></TD></TR>
<TR vAlign=center align=left>
<TD vAlign=top bgColor=#bdcff7 colSpan=2 height=24>
<TABLE cellSpacing=0 cellPadding=0 width="100%"
border=0>
<TBODY>
<TR>
<TD width=1></TD>
<TD align=right width=24><A
onmouseover="MM_swapImage('Image5','','images/home2.png',1)"
onmouseout=MM_swapImgRestore()
href="http://www.ie586.net/"><IMG title=返回页面
height=22 src="经典c程序100例==71--80.files/home.png"
width=24 border=0 name=Image5></A></TD>
<TD align=right width=24><A
onmouseover="MM_swapImage('Image4','','images/re_write2.gif',1)"
onmouseout=MM_swapImgRestore()
href="http://210.76.63.207/lb5000/leoboard.cgi"><IMG
title=发表评论 height=19
src="经典c程序100例==71--80.files/re_write.gif"
width=20 border=0 name=Image4></A></TD>
<TD width=24>
<DIV align=center><A
onclick="window.print();return false"
href="http://www.vcok.com/class/list.asp?id=210#"><IMG
onmouseover="MM_swapImage('p','','images/print2.png',1)"
height=22 alt=打印文档
src="经典c程序100例==71--80.files/print.png" width=24
border=0 name=p></A></DIV></TD>
<TD width=2></TD>
<TD class=zi vAlign=center width=308
height=25><FONT size=2> 文字 <SELECT
style="WIDTH: 60px; HEIGHT: 20px; fontsize: 9pt"
onchange=setFontColor(this.value);
name=seltextcolor> <OPTION value=#000000
selected>黑色</OPTION> <OPTION
value=#FFFFFF>白色</OPTION> <OPTION
value=#FF0000>红色</OPTION> <OPTION
value=#555555>灰色</OPTION> <OPTION
value=#00FF00>绿色</OPTION> <OPTION
value=#0000FF>蓝色</OPTION> <OPTION
value=#00cccc>青色</OPTION> <OPTION
value=#ffff00>黄色</OPTION></SELECT> 背景 <SELECT
style="WIDTH: 60px; HEIGHT: 20px; fontsize: 9pt"
onchange=setBgColor(this.value); name=selbkcolor>
<OPTION value=#FFFFFF selected>白色</OPTION>
<OPTION value=#000000>黑色</OPTION> <OPTION
value=#FFCCFF>粉红</OPTION> <OPTION
value=#CCCCCC>灰色</OPTION> <OPTION
value=#CCFFCC>绿色</OPTION> <OPTION
value=#99CCFF>蓝色</OPTION> <OPTION
value=#CCFFFF>青色</OPTION> <OPTION
value=#FFCCCC>综色</OPTION></SELECT> 字号 <SELECT
style="WIDTH: 60px; HEIGHT: 20px; fontsize: 9pt"
onchange=setFontSize(this.value);
name=selfontsize> <OPTION value=9pt selected>9
pt</OPTION> <OPTION value=10pt>10 pt</OPTION>
<OPTION value=12pt>12 pt</OPTION> <OPTION
value=14pt>14 pt</OPTION> <OPTION value=16pt>16
pt</OPTION> <OPTION value=19pt>19
pt</OPTION></SELECT> </FONT></TD>
<TD class=zi width=85><FONT size=2><A
onmouseover="MM_showHideLayers('Layer1','','show')"
onmouseout="MM_showHideLayers('Layer1','','hide')"
href="javascript:saveit();"><IMG
onmouseover="MM_swapImage('s','','images/save2.png',1)"
height=22 src="经典c程序100例==71--80.files/save.png"
width=23 align=absBottom border=0
name=s></A>保存设置</FONT></TD>
<TD class=zi width=2><FONT size=2> </FONT></TD>
<TD class=zi width=164><FONT
size=2> 人气指数:<FONT
color=#ff0000>20699</FONT>
</FONT></TD></TR></TBODY></TABLE></TD></TR>
<TR vAlign=center align=left>
<TD bgColor=#bdcff7 colSpan=2 height=370>
<TABLE height=360 cellSpacing=0 borderColorDark=#4275d6
cellPadding=5 width=640 align=center bgColor=#ffffff
borderColorLight=#ffffff border=1>
<TBODY>
<TR vAlign=top align=left>
<TD id=thetd style="FONT-SIZE: 10pt">
<DIV style="WIDTH: 626px; HEIGHT: 132px"
align=left>
<P align=left>
<STYLE type=text/css>TD {
FONT-SIZE: 9pt
}
BODY {
FONT-SIZE: 9pt; COLOR: #000000; LINE-HEIGHT: 150%
}
A:link {
COLOR: #000000; TEXT-DECORATION: none
}
A:visited {
COLOR: #000000; TEXT-DECORATION: none
}
A:active {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #ff0000; TEXT-DECORATION: underline
}
</STYLE>
<P align=left><FONT color=#ff9933><B><FONT
size=5> <FONT
color=#3300cc>经典c程序100例==71--80</FONT></FONT></B></FONT></P>
<P><FONT
color=#990000>【程序71】</FONT><BR>题目:编写input()和output()函数输入,输出5个学生的数据记录。<BR>1.程序分析:<BR>2.程序源代码:<BR>#define
N 5<BR>struct student<BR>{ char num[6];<BR> char
name[8];<BR> int score[4];<BR>}
stu[N];<BR>input(stu)<BR>struct student
stu[];<BR>{ int i,j;<BR> for(i=0;i<N;i++)<BR> {
printf("\n please input %d of
%d\n",i+1,N);<BR> printf("num:
");<BR> scanf("%s",stu[i].num);<BR> printf("name:
");<BR> scanf("%s",stu[i].name);<BR> for(j=0;j<3;j++)<BR> {
printf("score
%d.",j+1);<BR> scanf("%d",&stu[i].score[j]);<BR> }<BR> printf("\n");<BR> }<BR>}<BR>print(stu)<BR>struct
student stu[];<BR>{ int i,j;<BR>printf("\nNo. Name
Sco1 Sco2 Sco3\n");<BR>for(i=0;i<N;i++)<BR>{
printf("%-6s%-10s",stu[i].num,stu[i].name);<BR> for(j=0;j<3;j++)<BR> printf("%-8d",stu[i].score[j]);<BR> printf("\n");<BR>}<BR>}<BR>main()<BR>{<BR> input();<BR> print();<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序72】</FONT><BR>题目:创建一个链表。<BR>1.程序分析: <BR>2.程序源代码:<BR>/*creat
a list*/<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>void main()<BR>{
link ptr,head;<BR>int
num,i;<BR>ptr=(link)malloc(sizeof(node));<BR>ptr=head;<BR>printf("please
input 5
numbers==>\n");<BR>for(i=0;i<=4;i++)<BR>{<BR> scanf("%d",&num);<BR> ptr->data=num;<BR> ptr->next=(link)malloc(sizeof(node));<BR> if(i==4)
ptr->next=NULL;<BR> else
ptr=ptr->next;<BR>}<BR>ptr=head;<BR>while(ptr!=NULL)<BR>{
printf("The value is
==>%d\n",ptr->data);<BR> ptr=ptr->next;<BR>}<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序73】</FONT><BR>题目:反向输出一个链表。 <BR>1.程序分析:<BR>2.程序源代码:<BR>/*reverse
output a list*/<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>void main()<BR>{
link ptr,head,tail; <BR> int
num,i;<BR> tail=(link)malloc(sizeof(node));<BR> tail->next=NULL;<BR> ptr=tail;<BR> printf("\nplease
input 5
data==>\n");<BR> for(i=0;i<=4;i++)<BR> {<BR> scanf("%d",&num);<BR> ptr->data=num;<BR> head=(link)malloc(sizeof(node));<BR> head->next=ptr;<BR> ptr=head;<BR> }<BR>ptr=ptr->next;<BR>while(ptr!=NULL)<BR>{
printf("The value is
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -