📄 list10.htm
字号:
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 href="javascript:saveit();" onMouseOver="MM_showHideLayers('Layer1','','show')" onMouseOut="MM_showHideLayers('Layer1','','hide')"><img src="images/save.png" width="23" height="22" name="s" onMouseOver="MM_swapImage('s','','images/save2.png',1)" border="0" align="absbottom"></a>保存设置</font></TD>
<TD class=zi width=2 ><font size="2"> </font></TD>
<TD class=zi width=164><font size="2"> 人气指数:<font color="#FF0000">162368</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 align="left" style="width: 626; height: 132">
<p align="left">
<html>
<head>
<style type="text/css">
td { font-size: 9pt }
body { color: #000000; font-size: 9pt; 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>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<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("| | |");<br>
gotoxy(1,18);printf("| | |");<br>
gotoxy(1,19);printf("| | |");<br>
gotoxy(1,20);printf("| | |");<br>
gotoxy(1,21);printf("| | |");<br>
gotoxy(1,22);printf("| | |");<br>
gotoxy(1,23);printf("|---------------------------------------------------------------------------|");<br>
i=0;<br>
getdate(&d);<br>
sprintf(chtime,"%4d.%02d.%02d",d.da_year,d.da_mon,d.da_day);<br>
for(;;)<br>
{<br>
gotoxy(3,24);printf(" Tab __browse cost list Esc __quit");<br>
gotoxy(13,10);printf(" ");<br>
gotoxy(13,13);printf(" ");<br>
gotoxy(13,7);printf("%s",chtime);<br>
j=18;<br>
ch[0]=getch();<br>
if(ch[0]==27)<br>
break;<br>
strcpy(chshop,"");<br>
strcpy(chmoney,"");<br>
if(ch[0]==9)<br>
{<br>
mm:i=0;<br>
fp=fopen("home.dat","r+");<br>
gotoxy(3,24);printf(" ");<br>
gotoxy(6,4);printf(" list records ");<br>
gotoxy(1,5);printf("|-------------------------------------|");<br>
gotoxy(41,4);printf(" ");<br>
gotoxy(41,5);printf(" |");<br>
while(fscanf(fp,"%10s%14s%f\n",chtime,chshop,&chm)!=EOF)<br>
{ if(i==36)<br>
{ getch();<br>
i=0;}<br>
if ((i%36)<17)<br>
{ gotoxy(4,6+i);<br>
printf(" ");<br>
gotoxy(4,6+i);}<br>
else<br>
if((i%36)>16)<br>
{ gotoxy(41,4+i-17);<br>
printf(" ");<br>
gotoxy(42,4+i-17);}<br>
i++;<br>
sum=sum+chm;<br>
printf("%10s %-14s %6.1f\n",chtime,chshop,chm);}<br>
gotoxy(1,23);printf("|---------------------------------------------------------------------------|");<br>
gotoxy(1,24);printf("| |");<br>
gotoxy(1,25);printf("|---------------------------------------------------------------------------|");<br>
gotoxy(10,24);printf("total is %8.1f$",sum);<br>
fclose(fp);<br>
gotoxy(49,24);printf("press any key to.....");getch();goto pp;<br>
}<br>
else<br>
{<br>
while(ch[0]!='\r')<br>
{ if(j<10)<br>
{ strncat(chtime,ch,1);<br>
j++;}<br>
if(ch[0]==8)<br>
{<br>
len=strlen(chtime)-1;<br>
if(j>15)<br>
{ len=len+1; j=11;}<br>
strcpy(ch1,"");<br>
j=j-2;<br>
strncat(ch1,chtime,len);<br>
strcpy(chtime,"");<br>
strncat(chtime,ch1,len-1);<br>
gotoxy(13,7);printf(" ");}<br>
gotoxy(13,7);printf("%s",chtime);ch[0]=getch();<br>
if(ch[0]==9)<br>
goto mm;<br>
if(ch[0]==27)<br>
exit(1);<br>
}<br>
gotoxy(3,24);printf(" ");<br>
gotoxy(13,10);<br>
j=0;<br>
ch[0]=getch();<br>
while(ch[0]!='\r')<br>
{ if (j<14)<br>
{ strncat(chshop,ch,1);<br>
j++;}<br>
if(ch[0]==8)<br>
{ len=strlen(chshop)-1;<br>
strcpy(ch1,"");<br>
j=j-2;<br>
strncat(ch1,chshop,len);<br>
strcpy(chshop,"");<br>
strncat(chshop,ch1,len-1);<br>
gotoxy(13,10);printf(" ");}<br>
gotoxy(13,10);printf("%s",chshop);ch[0]=getch();}<br>
gotoxy(13,13);<br>
j=0;<br>
ch[0]=getch();<br>
while(ch[0]!='\r')<br>
{ if (j<6)<br>
{ strncat(chmoney,ch,1);<br>
j++;}<br>
if(ch[0]==8)<br>
{ len=strlen(chmoney)-1;<br>
strcpy(ch1,"");<br>
j=j-2;<br>
strncat(ch1,chmoney,len);<br>
strcpy(chmoney,"");<br>
strncat(chmoney,ch1,len-1);<br>
gotoxy(13,13);printf(" ");}<br>
gotoxy(13,13);printf("%s",chmoney);ch[0]=getch();}<br>
if((strlen(chshop)==0)||(strlen(chmoney)==0))<br>
continue;<br>
if((fp=fopen("home.dat","a+"))!=NULL);<br>
fprintf(fp,"%10s%14s%6s",chtime,chshop,chmoney);<br>
fputc('\n',fp);<br>
fclose(fp);<br>
i++;<br>
gotoxy(41,5+i);<br>
printf("%10s %-14s %-6s",chtime,chshop,chmoney);<br>
}}} <br>
==============================================================<br>
<font color="#990000">【程序96】</font><br>
题目:计算字符串中子串出现的次数<br>
1.程序分析:<br>
2.程序源代码:<br>
#include "string.h"<br>
#include "stdio.h"<br>
main()<br>
{ char str1[20],str2[20],*p1,*p2;<br>
int sum=0;<br>
printf("please input two strings\n");<br>
scanf("%s%s",str1,str2);<br>
p1=str1;p2=str2;<br>
while(*p1!='\0')<br>
{<br>
if(*p1==*p2)<br>
{while(*p1==*p2&&*p2!='\0')<br>
{p1++;<br>
p2++;}<br>
}<br>
else<br>
p1++;<br>
if(*p2=='\0')<br>
sum++;<br>
p2=str2;<br>
}<br>
printf("%d",sum);<br>
getch();} <br>
==============================================================<br>
<font color="#990000">【程序97】</font><br>
题目:从键盘输入一些字符,逐个把它们送到磁盘上去,直到输入一个#为止。<br>
1.程序分析: <br>
2.程序源代码:<br>
#include "stdio.h"<br>
main()<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -