📄 经典c程序100例==91--100.htm
字号:
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例==91--100.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例==91--100:.:.</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例==91--100.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例==91--100.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例==91--100.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=212#"><IMG
onmouseover="MM_swapImage('p','','images/print2.png',1)"
height=22 alt=打印文档
src="经典c程序100例==91--100.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例==91--100.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>54282</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例==91--100</FONT></FONT></B></FONT></P>
<P><FONT
color=#990000>【程序91】</FONT><BR>题目:时间函数举例1<BR>1.程序分析:<BR>2.程序源代码:<BR>#include
"stdio.h"<BR>#include "time.h"<BR>void main()<BR>{
time_t lt; /*define a longint time
varible*/<BR>lt=time(NULL);/*system time and
date*/<BR>printf(ctime(<)); /*english format
output*/<BR>printf(asctime(localtime(<)));/*tranfer
to tm*/<BR>printf(asctime(gmtime(<)));
/*tranfer to Greenwich
time*/<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序92】</FONT><BR>题目:时间函数举例2<BR>1.程序分析: <BR>2.程序源代码:<BR>/*calculate
time*/<BR>#include "time.h"<BR>#include
"stdio.h"<BR>main()<BR>{ time_t start,end;<BR>int
i;<BR>start=time(NULL);<BR>for(i=0;i<3000;i++)<BR>{
printf("\1\1\1\1\1\1\1\1\1\1\n");}<BR>end=time(NULL);<BR>printf("\1:
The different is
%6.3f\n",difftime(end,start));<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序93】</FONT><BR>题目:时间函数举例3<BR>1.程序分析:<BR>2.程序源代码:<BR>/*calculate
time*/<BR>#include "time.h"<BR>#include
"stdio.h"<BR>main()<BR>{ clock_t start,end;<BR>int
i;<BR>double
var;<BR>start=clock();<BR>for(i=0;i<10000;i++)<BR>{
printf("\1\1\1\1\1\1\1\1\1\1\n");}<BR>end=clock();<BR>printf("\1:
The different is
%6.3f\n",(double)(end-start));<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序94】</FONT><BR>题目:时间函数举例4,一个猜数游戏,判断一个人反应快慢。(版主初学时编的)<BR>1.程序分析:<BR>2.程序源代码:<BR>#include
"time.h"<BR>#include "stdlib.h"<BR>#include
"stdio.h"<BR>main()<BR>{char c;<BR>clock_t
start,end;<BR>time_t a,b;<BR>double var;<BR>int
i,guess;<BR>srand(time(NULL));<BR>printf("do you
want to play it.('y' or 'n')
\n");<BR>loop:<BR>while((c=getchar())=='y')<BR>{<BR>i=rand()%100;<BR>printf("\nplease
input number you
guess:\n");<BR>start=clock();<BR>a=time(NULL);<BR>scanf("%d",&guess);<BR>while(guess!=i)<BR>{if(guess>i)<BR>{printf("please
input a little
smaller.\n");<BR>scanf("%d",&guess);}<BR>else<BR>{printf("please
input a little
bigger.\n");<BR>scanf("%d",&guess);}<BR>}<BR>end=clock();<BR>b=time(NULL);<BR>printf("\1:
It took you %6.3f
seconds\n",var=(double)(end-start)/18.2);<BR>printf("\1:
it took you %6.3f
seconds\n\n",difftime(b,a));<BR>if(var<15)<BR>printf("\1\1
You are very clever! \1\1\n\n");<BR>else
if(var<25)<BR>printf("\1\1 you are normal!
\1\1\n\n");<BR>else<BR>printf("\1\1 you are
stupid! \1\1\n\n");<BR>printf("\1\1
Congradulations \1\1\n\n");<BR>printf("The number
you guess is %d",i);<BR>}<BR>printf("\ndo you want
to try it
again?(\"yy\".or.\"n\")\n");<BR>if((c=getch())=='y')<BR>goto
loop;<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序95】</FONT><BR>题目:家庭财务管理小程序<BR>1.程序分析:<BR>2.程序源代码:<BR>/*money
management system*/<BR>#include
"stdio.h"<BR>#include
"dos.h"<BR>main()<BR>{<BR>FILE *fp;<BR>struct date
d;<BR>float sum,chm=0.0;<BR>int len,i,j=0;<BR>int
c;<BR>char
ch[4]="",ch1[16]="",chtime[12]="",chshop[16],chmoney[8];<BR>pp:
clrscr();<BR>sum=0.0;<BR>gotoxy(1,1);printf("|---------------------------------------------------------------------------|");<BR>gotoxy(1,2);printf("|
money management system(C1.0) 2000.03
|");<BR>gotoxy(1,3);printf("|---------------------------------------------------------------------------|");<BR>gotoxy(1,4);printf("|
-- money records -- | -- today cost list --
|");<BR>gotoxy(1,5);printf("|
------------------------
|-------------------------------------|");<BR>gotoxy(1,6);printf("|
date: -------------- |
|");<BR>gotoxy(1,7);printf("| | | |
|");<BR>gotoxy(1,8);printf("| -------------- |
|");<BR>gotoxy(1,9);printf("| thgs:
------------------ |
|");<BR>gotoxy(1,10);printf("| | | |
|");<BR>gotoxy(1,11);printf("| ------------------
| |");<BR>gotoxy(1,12);printf("| cost: ----------
| |");<BR>gotoxy(1,13);printf("| | | |
|");<BR>gotoxy(1,14);printf("| ---------- |
|");<BR>gotoxy(1,15);printf("| |
|");<BR>gotoxy(1,16);printf("| |
|");<BR>gotoxy(1,17);printf("| |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -