Archive for 十月, 2011

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

//q1.c
#include <stdio.h>
int main(int argc, char *argv[])
{
    //變數宣告 
    int a, b;
 
    //從main()函數輸入參數 
    a = atoi(argv[1]);
    b = atoi(argv[2]);
 
    //從printf()輸出 
    printf("%d / %d = %d ... %d", a, b, a/b, a%b);
    return 0;
}
//q2.c
#include <stdio.h>
int main(int argc, char *argv[])
{
    //變數宣告 
    int num1, num2, num3;
 
    //從main()函數輸入參數 
     num1 = atoi(argv[1]);
     num2 = atoi(argv[2]);
     num3 = atoi(argv[3]);
 
    //從printf()輸出 
    if (num1 > num2 && num1 > num3)
       printf ("The biggest is %d", num1);
    else if (num2 > num3)
       printf ("The biggest is %d", num2);
    else
       printf ("The biggest is %d", num3);
 
    return 0;
}
//q3.c
#include <stdio.h>
int main(int argc, char *argv[])
{
    //變數宣告 
    int num1;
    int i;
 
    //從main()函數輸入參數 
     num1 = atoi(argv[1]);
 
    //流程控制
    for (i=0; i<  num1; i++)
    {
        printf("%d ", num1);
    }
 
    return 0;
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,