当前位置:网站首页>Notes on writing questions in C language -- free falling ball

Notes on writing questions in C language -- free falling ball

2022-06-23 04:41:00 Fanyi

 Insert picture description here

subject

A ball from 100 Free fall at meter height , Jump back to half of the original height after landing ; And then fall , Ask it in the 10 The next landing , How many meters in total ? The first 10 How high is the rebound ?

Ideas

Use the cycle to find half of the height and add it .

Answer key

#include <stdio.h>

int main()
{
    
    float sn=100.0,hn=sn/2;
    int n;
    
    for(n=2;n<=10;n++)
    {
    
        sn=sn+2*hn; // The first  n  The total number of meters passed during the first landing 
        hn=hn/2;    // The first  n  Second bounce height 
    }
    
    printf(" Common course  %.2f  rice \n",sn);
    printf(" Ground ten bounce high  %.2f  rice \n",hn);
}

Sample output

 Insert picture description here

 Insert picture description here

原网站

版权声明
本文为[Fanyi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206222333267473.html