Archive for 十一月, 2011

1128Prog

模擬大量資料的程式

模擬大量資料的程式

產生模擬資料到檔案的二種方式:(1) command pipeline(2) file open/close

產生模擬資料到檔案的二種方式:(1) command pipeline(2) file open/close

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
void lotto_num(int lotto[6]);
int main(int argc, char *argv[])
{
    int i;
    int N;
    //int ticket[6];
    FILE *file;
    //從main()參數讀入一個整數 N
    N = atoi(argv[1]); 
 
    srand( (unsigned) time( NULL ) );
 
    //file = fopen("lotto.txt", "w");
    for (i=0; i<N; i++)
    {
     //lotto_num(ticket);
     printf (" %2d %2d %2d %2d %2d %2d\n", 
        ticket[0], ticket[1], ticket[2], ticket[3], ticket[4], ticket[5]);
    }
 
    //fclose(file);
    return 0;
}
void lotto_num(int lotto[6])
{
     int i, j;
     int max, num;
     int ball[49];
     for (i =0; i< 49; i++)
     {
        ball[i] = rand();//每個球給它一個比重 
        printf(" %d", ball[i]);
     }
    printf("\n");
 
    for (j =0; j<6; j++)
    {
        //每次挑最重的一顆球 
        max = -1; num= -1;
        for (i =0; i< 49; i++)
        {   
            if (ball[i] > max)
            {
               max = ball[i]; num = i+1;            
            }
        }
        ball[num-1] = 0;//比重歸零 
        //lotto[j]= num;
    }
 }

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
void lotto_num(int lotto[6]);
int main(int argc, char *argv[])
{
    int i;
    int N;
    int ticket[6];
    //從main()參數讀入一個整數 N
    N = atoi(argv[1]);
 
    srand( (unsigned) time( NULL ) )
 
    for (i=0; i<N; i++)
    {
     //lotto_num(ticket);
     printf (" %2d %2d %2d %2d %2d %2d\n", 
        ticket[0], ticket[1], ticket[2], ticket[3], ticket[4], ticket[5]);
    }
 
    return 0;
}
void lotto_num(int lotto[6])
{
     int i, j;
     int max, num;
     int ball[49];
     for (i =0; i< 49; i++)
     {
        ball[i] = rand();//每個球給它一個比重 
     }
 
    for (j =0; j<6; j++)
    {
        //每次挑最重的一顆球 
        max = -1; num= -1;
        for (i =0; i< 49; i++)
        {   
            if (ball[i] > max)
            {
               max = ball[i]; num = i+1;            
            }
        }
        ball[num-1] = 0;//比重歸零 
    }
 }

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

1124Math

微分的應用-最大或最小值

微分的應用-最大或最小值

 

指數函數的複習

指數函數的複習

微分的應用-變化率

微分的應用-變化率

 

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

1124Info

1970年代電玩的發展

1970年代電玩的發展

數位內容製作

數位內容製作

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,