Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //8
- #include <iostream>
- int main() {
- int k=0;
- double hight_k,width_k;
- std::cout << "Enter the width and height of the envelope\n";
- std::cin >> hight_k >> width_k;
- if ((!(std::cin))||(hight_k<=0)||(width_k<=0))
- {
- std::cerr<<"Input is incorrect\n";
- return 1;
- }
- double hight_p,width_p;
- std::cout << "Enter the width and hight of the letter \n";
- std::cin >> hight_p >> width_p;
- if ((!(std::cin))||(hight_p<=0)||(width_k<=0))
- {
- std::cerr <<"Input is incorrect\n";
- return 1;
- }
- while (hight_p > hight_k || width_p > width_k) {
- std::cout << "Meauserements of letter " << width_p << "x\n" << hight_p ;
- if ((hight_k>=width_p)&&(width_k>=hight_p))
- {
- std::cout << "Ok";
- break;
- return 0;
- }
- if (hight_p > width_p)
- { k=k+width_p/2;
- hight_p /= 2;}
- else
- {
- k=k+hight_p/2;
- width_p /= 2;
- }
- }
- std::cout << "The letter will fit into the envelope: " << width_p << "x\n" << hight_p ;
- std::cout <<"Sum" <<k;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement