fork(1) download
  1. #include <cstdio>
  2.  
  3. int main()
  4. {
  5. auto aspect_ratio = 17.0 / 7.0;
  6. int image_width = 400;
  7.  
  8. int image_height = image_width / aspect_ratio;
  9.  
  10. auto viewport_height = 2.0;
  11. auto viewport_width = viewport_height * image_width / image_height;
  12.  
  13. printf("Aspect ratio: %f\n", aspect_ratio);
  14. printf("Image: %d x %d\n", image_width, image_height);
  15. printf("Viewport: %f x %f\n", viewport_width, viewport_height);
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Aspect ratio: 2.428571
Image: 400 x 164
Viewport: 4.878049 x 2.000000