Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I had to do a code for this program and with your help I'm nearly finished. But I still need to do the : //

I had to do a code for this program and with your help I'm nearly finished. But I still need to do the :

// Other member functions

size_t get_base() const; // Returns the base that the Uint is currently in

void set_base(size_t base); // Sets the base of the Uint

size_t get_size() const; // Returns the number of digits in the Uint

void set_size(size_t size); // Sets the number of digits in the Uint

friend std::ostream& operator<<(std::ostream& out, const Uint& x);

this is the basic main, as said before I can't change it 
#include  #include "prime.hpp" #include "Uint.hpp" using namespace std; Uint fibo(size_t n) { Uint f_i_moins_1(0), f_i(1), f_i_plus_1; if (n == 0) return f_i_moins_1; if (n == 1) return f_i; for (size_t i = 2; i <= n; i++){ f_i_plus_1 = f_i_moins_1 + f_i; f_i_moins_1 = f_i; f_i = f_i_plus_1; } return f_i; } Uint factorielle(size_t n) { Uint res(1); for (size_t i = 2; i <= n; i++) res *= i; return res; } int main() { Uint a(10); cout << "Constructeur avec size_t OK "; Uint b; cout << "Constructeur vide OK "; b = 3; cout << "Affectation OK "; const Uint c = 13; cout << uint64_t(c) << " = 13: cast explicite vers uint64_t "; if (a < c) cout << "Operateur < OK "; else cout << "a < c : " << (a < c) << " pas bon!!! "; b += a; cout << "Operateur+= "; if (c == b) cout << "Comparaison == OK "; else cout << "c == b : " << (c == b) << " Operateur == ou += pas bon!!! "; a = fibo(50); cout << "fibo(50) "; b = fibo(51); const Uint d = fibo(52); if (d == a + b) cout << "Operateur+ OK "; else cout << "+ ou == pas bon!!! "; if (d - b != a) cout << "- ou != pas bon!!! "; else cout << "Operateur- OK "; a = factorielle(50); cout << "Factorielle "; b = factorielle(51); if (51 * a == b) cout << "Operateur* et *= OK "; else cout << "* ou *= ou == pas bon!!! "; if (51 != b / a) cout << "/ ou != pas bon!!! "; else cout << "Operateur/ OK "; cout << "51! en base 10 = " << b << endl; // Le modificateur set_base(...) n'affecte que la prochaine impression d'un Uint cout << set_base(16) << "Modificateur d'impression Uint "; cout << "51! en base 16 = " << b << endl; cout << "52e terme de la suite de Fibonacci, en base 10 = " << d << endl; a = 1; a <<= 99; cout << "Operateur <<= "; cout << "2 ^ 99 = " << a << endl; b = (Uint(1) << 100) -1; cout << "Operateur << "; cout << set_base(16, LOWER_CASE); cout << "2 ^ 100 - 1 (base 16, bas de casse) = " << b << endl; cout << "10 plus petits nombres premiers > 2^99 "; size_t nb = 0; while (nb < 10) { if (prime(a)) { cout << a << endl; nb++; } ++a; } cout << "10 plus grands nombres premiers < 2^100 "; nb = 0; while (nb < 10) { if (prime(b)) { cout << b << endl; nb++; } --b; } /* Rsultat de l'excution: Constructeur avec size_t OK Constructeur vide OK Affectation OK 13 = 13: cast explicite vers uint64_t Operateur < OK Operateur+= Comparaison == OK fibo(50) Operateur+ OK Operateur- OK Factorielle Operateur* et *= OK Operateur/ OK 51! en base 10 = 1551118753287382280224243016469303211063259720016986112000000000000 Modificateur d'impression Uint 51! en base 16 = EBA8F91E823EE3E18972ACC521C1C87CED2093CFDBE800000000000 52e terme de la suite de Fibonacci, en base 10 = 32951280099 Operateur <<= 2 ^ 99 = 633825300114114700748351602688 Operateur << 2 ^ 100 - 1 (base 16, bas de casse) = fffffffffffffffffffffffff 10 plus petits nombres premiers > 2^99 633825300114114700748351602943 633825300114114700748351603131 633825300114114700748351603197 633825300114114700748351603263 633825300114114700748351603341 633825300114114700748351603389 633825300114114700748351603407 633825300114114700748351603431 633825300114114700748351603467 633825300114114700748351603477 10 plus grands nombres premiers < 2^100 1267650600228229401496703205361 1267650600228229401496703205277 1267650600228229401496703205223 1267650600228229401496703205193 1267650600228229401496703205109 1267650600228229401496703205091 1267650600228229401496703205019 1267650600228229401496703204897 1267650600228229401496703204773 1267650600228229401496703204543 */ }

and the class I us, like this:

#include  using namespace std; class Uint { private: string nb; public: Uint(); explicit Uint(size_t a);//Overload constructeur explicit operator uint64_t() const; };//LABO21_UINT_H #endif 

I achived the other functioons etc

I thank you for your help

This is the link for my first question that you gave me an answer earlier

https://www.chegg.com/homework-help/questions-and-answers/c-programming-programme-main-given-rights-change-make-work-main-looks-like-programme-de-te-q106964760?recommendationId=87df1dd1-84c3-4e15-926c-aa4b8dc2f7e3®ionName=recent%20activity§ionId=f1646542-cb05-4198-bf8c-d027afb8db98

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions