2009年9月28日 星期一

輸入feet轉換成cm

#include <stdio.h>
int main(void)
{
    float feet,cm;

    printf("Key feet:");

    //這行是輸入數字的語法,請點選框框打上數字。
    scanf("%f",&feet);

    //吋轉換成公分。
    cm=feet*2.54;

    printf("\ncm=%f",cm);

    //這行是讓程式暫停的語法。
    system("pause");

return 0;
}


//鍵入數字:













//Linux下的PAUSE
#include <stdio.h>
#define PAUSE print("Press any key to continue..."); fgetc(stdin);

    int main(void)
    {
        PAUSE

        printf("system(\*pause\*) for linux \n");
        return 0;
    }

沒有留言:

張貼留言