In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
 
            
                     
                
2025-10-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
The editor would like to share with you the example analysis of C++ rational number expression and calculation. I believe most people don't know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's take a look at it!
# ifndef Rational_hpp#define Rational_hpp#include # include using namespace std;class Radtional {public: Radtional (); Radtional (int numerator,int denominator); int getNumerator () const; int getDemominator () const; Radtional add (const Radtional& secondRational); Radtional sub (const Radtional& secondRational); Radtional mult (const Radtional& secondRational); Radtional div (const Radtional& secondRational); int compareTo (const Radtional& secondRational); bool equals (const Radtional& secondRational); int intValue () Double doubleValue (); string toString (); private: int numerator,denominator; static int gcd (int npenint d);}; # endif / * Rational_hpp * / # include "Rational.hpp" # include # include Radtional::Radtional () {numerator = 0; denominator = 1;} Radtional::Radtional (int numerator,int denominator) {int factor = gcd (numerator,denominator); this- > numerator = (numerator > 0)? 1:-1) * abs (numerator) / factor This- > denominator = abs (denominator) / factor;} int Radtional::getNumerator () const {return numerator;} int Radtional::getDemominator () const {return denominator;} int Radtional::gcd (int n, int d) {int N1 = abs (n); int N2 = abs (d); int gcd = 1; for (int I = 1; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about

The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r


A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from

Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





 
             
            About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.