Archive for 一月, 2013

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[])
{
    int num, N;
 
 
    printf("A random number < %d -> %d", N, num);
    return 0;
}
===========================
#include <stdio.h>
int main()
{
   int i, ret, score;
   int max=0;
   FILE * stream;
   char filename[20]="score.txt";
 
   stream=fopen(filename, "r");
   ret=fscanf(stream,"%2d \n", &score);
...
   printf("The max score is %d", max);
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

2
一月

程式設計一程式 12/30: quiz2b

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

#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int num;
    int upper = 10;
    int digit = 1;
    printf("Input a number:");
    scanf("%d", &num);
 
    if (num <upper)
       printf("The number %d is %d digits", num, digit);
 
    while (num   upper)
    {
          upper*= 10
          digit++
          if (num <upper)
          printf("The number %d is %d digits", num, digit)
    }
    return 0;
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

2
一月

程式設計一程式 12/30: quiz2a

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

#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, char *argv[])
{
    int a, b, c, d;
    int sum;
    a = atoi(argv[1]);
    b = atoi(argv[2]);
    c = atoi(argv[3]);
    d = atoi(argv[4]);
 
    sum = a*a*a*a + b*b*b + c*c +d
 
    printf("(%d, %d, %d, %d) ans=%d", a, b, c, d, sum)
    return 0;
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,