Advertisement
Guest User

Untitled

a guest
Nov 15th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. //8
  2. #include <iostream>
  3.  
  4.  
  5. int main()  {
  6.     int k=0;
  7.     double hight_k,width_k;
  8.     std::cout << "Enter the width and height of the envelope\n";
  9.     std::cin >> hight_k >> width_k;
  10. if  ((!(std::cin))||(hight_k<=0)||(width_k<=0))
  11. {
  12.     std::cerr<<"Input is incorrect\n";
  13.  
  14.  
  15.     return  1;
  16. }
  17.     double hight_p,width_p;
  18.     std::cout << "Enter the width and hight of the letter \n";
  19.     std::cin >> hight_p >> width_p;
  20.     if  ((!(std::cin))||(hight_p<=0)||(width_k<=0))
  21.     {
  22.         std::cerr <<"Input is incorrect\n";
  23.  
  24.         return 1;
  25.     }
  26.  
  27.  
  28.     while (hight_p > hight_k || width_p > width_k) {
  29.         std::cout << "Meauserements of letter " << width_p  << "x\n" << hight_p  ;
  30.         if ((hight_k>=width_p)&&(width_k>=hight_p))
  31.         {
  32.             std::cout << "Ok";
  33.             break;
  34.             return 0;
  35.         }
  36.         if (hight_p > width_p)
  37.         {  k=k+width_p/2;
  38.             hight_p /= 2;}
  39.         else
  40.         {
  41.             k=k+hight_p/2;
  42.             width_p /= 2;
  43.  
  44. }
  45.     }
  46.  
  47.     std::cout << "The letter will fit into the envelope: " << width_p << "x\n" << hight_p ;
  48. std::cout <<"Sum" <<k;
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement