Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C++

ratio_not_equal trong C++

std::ratio_not_equal trong <ratio> kiểm tra 2 tỷ số phân số có khác nhau không (so sánh giá trị sau khi rút gọn).

Cú pháp

template <class R1, class R2> struct ratio_not_equal;

Ví dụ

#include <iostream>
#include <ratio>
using namespace std;

int main() {
    typedef ratio<2,5> R1;
    typedef ratio<1,3> R2;
    if (ratio_not_equal<R1,R2>::value)
        cout << "Khác nhau";
    else
        cout << "Bằng nhau";
    return 0;
}

Đầu ra

Khác nhau