标签:落地 scanf color bsp nbsp ++ lse 初始 res
1 #include<stdio.h> 2 3 int main() 4 { 5 int h, n, i; //h初始化高度,n次落地; 6 scanf_s("%d %d", &h, &n); 7 double result, h1; 8 9 if (n == 0) 10 { 11 result = 0; 12 h1 = 0; 13 } 14 else 15 { 16 result = h; //在空中经过的总距离 17 h1 = h / 2.0; //反弹的高度 18 19 for (i = 1; i < n; i++) 20 { 21 result = result + h1 * 2; 22 h1 = h1 / 2; 23 } 24 } 25 26 printf("%.1f %.1f", result, h1); 27 28 return 0; 29 }
标签:落地 scanf color bsp nbsp ++ lse 初始 res
原文地址:https://www.cnblogs.com/2018jason/p/10899063.html