12
十二月

程式設計一程式 12/12: 練習9 (ex9.c)

   Posted by: admin   in 101(上)程式設計(一)

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[])
{
    int N, i, num;
    FILE* stream;
    srand( (unsigned) time( NULL ) );
 
    N = atoi(argv[1]);
    printf("Numbers=%d\n", N);
 
    stream=fopen("record.txt", "w+");
 
    for (i=0; i< N;i++)
    {
       num = rand()%49+1;
       printf("%d\n", num);
       fprintf(stream, "%d\n", num);//print to file
    }
 
    fclose(stream);
 
    return 0;
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

This entry was posted on 星期三, 十二月 12th, 2012 at 10:03:02 and is filed under 101(上)程式設計(一). You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 Trackbacks/Pings

  1. Chad    七月 27 2014 / 3下午:

    pecs@crates.uncomforted” rel=”nofollow”>.…

    tnx….

  2. Jonathan    十一月 26 2014 / 5上午:

    irreconcilable@dilution.wergeland” rel=”nofollow”>.…

    áëàãîäàðåí!!…

  3. Joe    十二月 14 2014 / 6下午:

    conscription@brutally.considerately” rel=”nofollow”>.…

    thanks for information!!…

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment