⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 91.html

📁 经典C语言程序设计100例1-10 如【程序1】 题目:有1、2、3、4个数字
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<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%">&nbsp;</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 &quot;stdio.h&quot;<br>
        #include &quot;time.h&quot;<br>
        void main()<br>
        { time_t lt; /*define a longint time varible*/<br>
        lt=time(NULL);/*system time and date*/<br>
        printf(ctime(&lt;)); /*english format output*/<br>
        printf(asctime(localtime(&lt;)));/*tranfer to tm*/<br>
        printf(asctime(gmtime(&lt;))); /*tranfer to Greenwich time*/<br>
        }<br>
        ==============================================================<br>
        【程序92】<br>
        题目:时间函数举例2<br>
        1.程序分析:            <br>
        2.程序源代码:<br>
        /*calculate time*/<br>
        #include &quot;time.h&quot;<br>
        #include &quot;stdio.h&quot;<br>
        main()<br>
        { time_t start,end;<br>
        int i;<br>
        start=time(NULL);<br>
        for(i=0;i&lt;3000;i++)<br>
        { printf(&quot;\1\1\1\1\1\1\1\1\1\1\n&quot;);}<br>
        end=time(NULL);<br>
        printf(&quot;\1: The different is %6.3f\n&quot;,difftime(end,start));<br>
        }<br>
        ==============================================================<br>
        【程序93】<br>
        题目:时间函数举例3<br>
        1.程序分析:<br>
        2.程序源代码:<br>
        /*calculate time*/<br>
        #include &quot;time.h&quot;<br>
        #include &quot;stdio.h&quot;<br>
        main()<br>
        { clock_t start,end;<br>
        int i;<br>
        double var;<br>
        start=clock();<br>
        for(i=0;i&lt;10000;i++)<br>
        { printf(&quot;\1\1\1\1\1\1\1\1\1\1\n&quot;);}<br>
        end=clock();<br>
        printf(&quot;\1: The different is %6.3f\n&quot;,(double)(end-start));<br>
        }<br>
        ==============================================================<br>
        【程序94】<br>
        题目:时间函数举例4,一个猜数游戏,判断一个人反应快慢。(版主初学时编的)<br>
        1.程序分析:<br>
        2.程序源代码:<br>
        #include &quot;time.h&quot;<br>
        #include &quot;stdlib.h&quot;<br>
        #include &quot;stdio.h&quot;<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(&quot;do you want to play it.('y' or 'n') \n&quot;);<br>
        loop:<br>
        while((c=getchar())=='y')<br>
        {<br>
        i=rand()%100;<br>
        printf(&quot;\nplease input number you guess:\n&quot;);<br>
        start=clock();<br>
        a=time(NULL);<br>
        scanf(&quot;%d&quot;,&amp;guess);<br>
        while(guess!=i)<br>
        {if(guess&gt;i)<br>
        {printf(&quot;please input a little smaller.\n&quot;);<br>
        scanf(&quot;%d&quot;,&amp;guess);}<br>
        else<br>
        {printf(&quot;please input a little bigger.\n&quot;);<br>
        scanf(&quot;%d&quot;,&amp;guess);}<br>
        }<br>
        end=clock();<br>
        b=time(NULL);<br>
        printf(&quot;\1: It took you %6.3f seconds\n&quot;,var=(double)(end-start)/18.2);<br>
        printf(&quot;\1: it took you %6.3f seconds\n\n&quot;,difftime(b,a));<br>
        if(var&lt;15)<br>
        printf(&quot;\1\1 You are very clever! \1\1\n\n&quot;);<br>
        else if(var&lt;25)<br>
        printf(&quot;\1\1 you are normal! \1\1\n\n&quot;);<br>
        else<br>
        printf(&quot;\1\1 you are stupid! \1\1\n\n&quot;);<br>
        printf(&quot;\1\1 Congradulations \1\1\n\n&quot;);<br>
        printf(&quot;The number you guess is %d&quot;,i);<br>
        }<br>
        printf(&quot;\ndo you want to try it again?(\&quot;yy\&quot;.or.\&quot;n\&quot;)\n&quot;);<br>
        if((c=getch())=='y')<br>
        goto loop;<br>
        }<br>
        ==============================================================<br>
        【程序95】<br>
        题目:家庭财务管理小程序<br>
        1.程序分析:<br>
        2.程序源代码:<br>
        /*money management system*/<br>
        #include &quot;stdio.h&quot;<br>
        #include &quot;dos.h&quot;<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]=&quot;&quot;,ch1[16]=&quot;&quot;,chtime[12]=&quot;&quot;,chshop[16],chmoney[8];<br>
        pp: clrscr();<br>
        sum=0.0;<br>
        gotoxy(1,1);printf(&quot;|---------------------------------------------------------------------------|&quot;);<br>
        gotoxy(1,2);printf(&quot;| money management system(C1.0) 2000.03 |&quot;);<br>
        gotoxy(1,3);printf(&quot;|---------------------------------------------------------------------------|&quot;);<br>
        gotoxy(1,4);printf(&quot;| -- money records -- | -- today cost list -- 
        |&quot;);<br>
        gotoxy(1,5);printf(&quot;| ------------------------ |-------------------------------------|&quot;);<br>
        gotoxy(1,6);printf(&quot;| date: -------------- | |&quot;);<br>
        gotoxy(1,7);printf(&quot;| | | | |&quot;);<br>
        gotoxy(1,8);printf(&quot;| -------------- | |&quot;);<br>
        gotoxy(1,9);printf(&quot;| thgs: ------------------ | |&quot;);<br>
        gotoxy(1,10);printf(&quot;| | | | |&quot;);<br>
        gotoxy(1,11);printf(&quot;| ------------------ | |&quot;);<br>
        gotoxy(1,12);printf(&quot;| cost: ---------- | |&quot;);<br>
        gotoxy(1,13);printf(&quot;| | | | |&quot;);<br>
        gotoxy(1,14);printf(&quot;| ---------- | |&quot;);<br>
        gotoxy(1,15);printf(&quot;| | |&quot;);<br>
        gotoxy(1,16);printf(&quot;| | |&quot;);<br>
        gotoxy(1,17);printf(&quot;| | |&quot;);<br>
        gotoxy(1,18);printf(&quot;| | |&quot;);<br>
        gotoxy(1,19);printf(&quot;| | |&quot;);<br>
        gotoxy(1,20);printf(&quot;| | |&quot;);<br>
        gotoxy(1,21);printf(&quot;| | |&quot;);<br>
        gotoxy(1,22);printf(&quot;| | |&quot;);<br>
        gotoxy(1,23);printf(&quot;|---------------------------------------------------------------------------|&quot;);<br>
        i=0;<br>
        getdate(&amp;d);<br>
        sprintf(chtime,&quot;%4d.%02d.%02d&quot;,d.da_year,d.da_mon,d.da_day);<br>
        for(;;)<br>
        {<br>
        gotoxy(3,24);printf(&quot; Tab __browse cost list Esc __quit&quot;);<br>
        gotoxy(13,10);printf(&quot; &quot;);<br>
        gotoxy(13,13);printf(&quot; &quot;);<br>
        gotoxy(13,7);printf(&quot;%s&quot;,chtime);<br>
        j=18;<br>
        ch[0]=getch();<br>
        if(ch[0]==27)<br>
        break;<br>
        strcpy(chshop,&quot;&quot;);<br>
        strcpy(chmoney,&quot;&quot;);<br>
        if(ch[0]==9)<br>
        {<br>
        mm:i=0;<br>
        fp=fopen(&quot;home.dat&quot;,&quot;r+&quot;);<br>
        gotoxy(3,24);printf(&quot; &quot;);<br>
        gotoxy(6,4);printf(&quot; list records &quot;);<br>
        gotoxy(1,5);printf(&quot;|-------------------------------------|&quot;);<br>
        gotoxy(41,4);printf(&quot; &quot;);<br>
        gotoxy(41,5);printf(&quot; |&quot;);<br>
        while(fscanf(fp,&quot;%10s%14s%f\n&quot;,chtime,chshop,&amp;chm)!=EOF)<br>
        { if(i==36)<br>
        { getch();<br>
        i=0;}<br>
        if ((i%36)&lt;17)<br>
        { gotoxy(4,6+i);<br>
        printf(&quot; &quot;);<br>
        gotoxy(4,6+i);}<br>
        else<br>
        if((i%36)&gt;16)<br>
        { gotoxy(41,4+i-17);<br>
        printf(&quot; &quot;);<br>
        gotoxy(42,4+i-17);}<br>
        i++;<br>
        sum=sum+chm;<br>
        printf(&quot;%10s %-14s %6.1f\n&quot;,chtime,chshop,chm);}<br>
        gotoxy(1,23);printf(&quot;|---------------------------------------------------------------------------|&quot;);<br>
        gotoxy(1,24);printf(&quot;| |&quot;);<br>
        gotoxy(1,25);printf(&quot;|---------------------------------------------------------------------------|&quot;);<br>
        gotoxy(10,24);printf(&quot;total is %8.1f$&quot;,sum);<br>
        fclose(fp);<br>
        gotoxy(49,24);printf(&quot;press any key to.....&quot;);getch();goto pp;<br>
        }<br>
        else<br>
        {<br>
        while(ch[0]!='\r')<br>
        { if(j&lt;10)<br>
        { strncat(chtime,ch,1);<br>
        j++;}<br>
        if(ch[0]==8)<br>
        {<br>
        len=strlen(chtime)-1;<br>
        if(j&gt;15)<br>
        { len=len+1; j=11;}<br>
        strcpy(ch1,&quot;&quot;);<br>
        j=j-2;<br>
        strncat(ch1,chtime,len);<br>
        strcpy(chtime,&quot;&quot;);<br>
        strncat(chtime,ch1,len-1);<br>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -