Реализовать дробь — C++(Си)

#include <iostream>
#include <limits>
 
int main(){
    int a = 0, b = 0;
 
    while ( true ){
        std::cout << "A = ";
        std::cin >> a;
        if ( std::cin.fail() ){
            std::cerr << "Wrong A value!" << std::endl;
            std::cin.clear();
            std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
            continue;
        }
        std::cout << "B = ";
        std::cin >> b;
        if ( std::cin.fail() ){
            std::cerr << "Wrong B value!" << std::endl;
            std::cin.clear();
            std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
            continue;
        }
        break;
    }
 
    std::cout << "Fraction: " << a << " / " << b << std::endl;
 
    return 0;
}

One Thought to “Реализовать дробь — C++(Си)”

  1. Wow, marvelous blog format! How long have you ever been blogging for?

    you make blogging glance easy. The entire glance of your website is great,
    as neatly as the content! You can see similar here sklep internetowy

Leave a Comment