跳到主要內容
程式設計-C語言 / OLD / 訊二甲( 江 ) / 上學期 / 1022-CH5-運算子、百位數、++、--P132

 

 

1

BMI 計算

1

 
#include
 
int main()
{
    float high = 0, weight = 0, BMI = 0;
    printf("請輸入<身高(cm),體重(kg)>");
    scanf("%f,%f", &high, &weight );
    BMI = weight / ((high/100)*(high/100));
    printf("BMI = %.1f\n", BMI ); 
    return 0;
}
 

1

1

 

1

#include
 
int main() {
    int number = 0, a = 0;
    printf("請輸入數值");
    scanf("%d", &number );
    a = ( number / 100 ) % 10 ;
    printf("百位數字=%d\n", a ); 
    
    a = number;
    printf("++number = %d\n", ++number ); 
    number = a;
    printf("number++ = %d\n", number++ ); 
    printf("  number = %d\n", number ); 
    return 0;
}
 

 

時間類別單位標題發佈點閱
跳至網頁頂部