1 #include<stdio.h> 2 3 int main(void) 4 { 5 printf("请分别输入身高的英尺和英寸,""如输入"5 7"表示5英尺7英寸:"); 6 7 double foot; //双精度浮点数 8 double inch; 9 10 scanf_s("%lf %lf", &foot, &inch); //double型变量,输入时用%lf 11 12 printf("身高是%f米。 ", (foot + inch / 12) * 0.3048); 13 14 return 0; 15 }
1 #include<stdio.h> 2 3 int main(void) 4 { 5 int a, b; 6 7 scanf_s("%d %d", &a, &b); 8 9 double c = ((double)a + (double)b) / 2.0; //强制转换数据类型 10 11 printf("%d和%d的平均值=%f ", a, b, c); 12 13 return 0; 14 }