1020:c Language Programming Tutorial (third Edition) after class exercise 6.9

Source: Internet
Author: User

The title describes a ball from the M-meter height of the free fall, each landing after the return of the original height of half, and then fall. How high does it bounce when it lands on nth time? How many meters are there? Leave two-bit decimal input m n output how high does it bounce when it lands on nth time? How many meters are there? Keep two decimal places separated by spaces and put in one line sample input
1000 5
Sample output
31.25 2875.00
Hint Source

#include<stdio.h> int main() {      int m,n,i;      float h,l=0.0;      scanf ( "%d%d" ,&m,&n);      h=m;      for (i=1;i<=n;i++)      {          l+=1.5*h;          h=h/2;      }      l=l-h;      printf ( "%.2f %.2f" ,h,l); }

1020:c Language Programming Tutorial (third Edition) after class exercise 6.9

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.