📄 91.html
字号:
<html>
<head>
<title>C程序设计91-100</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="cc.css" type="text/css">
<link rel="stylesheet" href="cc.css" type="text/css">
</head>
<body bgcolor="#6666FF" text="#FFFFFF" link="#99FF33" alink="#00CC00" vlink="#FFFF00">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%"> </td>
<td class="unnamed1">
<div align="center"><font color="#FFFF00" size="5">经典c程序100例==91--100</font>
</div>
<p>【程序91】<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>
【程序92】<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>
【程序93】<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>
【程序94】<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>
【程序95】<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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -