#include<iostream> #include <cmath> #include <iomanip> using namespace std; long double a,b,c,a1,b1,x0,x1,x2,x3,x4,x5,x6,x7; long double det,d,e,f,v,w,y,z; long double q; long double Equat3(const long double ); long double Newton_method(); long double Check_result(const long double x ); int main(){ cout <<" pick values for ax^2 + bx + c : "<< endl; cout <<" Choose a : "; cin >> a; cout <<" Choose b : "; cin >> b; cout <<" Choose c : "; cin >> c; cout<<" your equation is "<< a << " x^2 + "<< b << " x + "<< c << " = 0 "<< endl; det = ((b*b)-(4*a*c)); if (det<0) cout <<" There is no real solution ... "; else { x1 =( -b + sqrt(det))/(2*a); cout <<" First root , x1 = "<< x1<< endl; x2 =( -b - sqrt(det))/(2*a); cout <<" Second root , x2 = "<< x2<< endl; } cout <<" Now , we'll write a cubic equation . \n Choose d : "; cin >> d; cout <<" your cubic equation is "<< a << " x^3 + "<< b << " x^2 + "<< c <<" x +"<< d << " = 0 "<< endl; x3 = Newton_method(); x4 = Check_result(x3); if(x4==0) cout<<" "<< x3 <<" is a good root !\n"; else { cout <<" "<< x3 <<" is not a root ...\n Do you want to retry ?\n"; int choice ; do{ cout <<" 1 = retry ; 0 = do not retry ;\n"; cin >> choice; switch(choice) { case 0: break; case 1: x3 = Newton_method(); x4 = Check_result(x3); if(x4==0)cout << x3 <<" is a good root !\n"; break; } }while(choice!=0);//end do while }//end else x6 = Check_result(x3); if(x6==0) cout<<" "<< x3 <<" is a good root !\n"; cout << endl<< endl<<" choose 2 values in the environment of the root BEWARE ->( v greater than w )!!! : "<< endl; cout <<" v = "; cin >> v; cout << endl<<" w = "; cin >> w; f = 0; cout<< endl<<" With bisection method , one root is : "<< endl; while(f<40) { y =((v-w)/2)+ w ; q = Equat3(y); if (q>0) {v = y; cout << y <<" "; if(f==39) z = y;} else if(q<0) {w = y; cout << y <<" "; if(f==39) z = y;} f++; y = q; }//end while x7 = Check_result(1.0);cout<< endl<< x7<<'\n'; cout << " \n Result is : "<< z <<'\n';long double ax = z; x7 = Check_result(ax); if(x7==0) cout << y<<" is a good root !\n"; char ze; cin >> ze; } long double Equat3(const long double x ) { long double Res ; Res = (a*x*x*x)+ (b*x*x)+ (c*x)+ d; return Res; } long double Newton_method() { a1 = 3*a; b1 = 2*b; cout << endl<<" Choose an approximative value for a root : "; cin >> x0; x3 = x0 -(Equat3(x0)/((a1*x0*x0)+(b1*x0)+c)); cout <<" With Newton's method , a root of the cubic equation is : "<< endl; e = 0; while(e<15) { x3 = x0 -(Equat3(x0)/((a1*x0*x0)+(b1*x0)+c)); e++; x0 = x3; cout<< x3 <<" "; } cout <<" \n Result is :"<< x3; return x3; } long double Check_result(const long double x ) { long double xr; cout<<" \n Check result : \n"; xr = Equat3(x); cout <<" Plugging "<< x <<" in the equation , it gives :"<< xr <<" ... \n"; return xr; }

Doubly linked list (4 files)

C++ again, for finding one root of a third degree equation and checking the result , it often works fine :

For finding the 93 first Fibonacci numbers very fast , after 93 iterations it is false :

A linked list for practising :

For finding the binary representation of a number using bits :

For finding the binary representation of a number using maths :

hexadecimal representation of a number using maths :

hexadecimal representation of a number using bits :

for well understanding the structure of a linked list, here is a simple one:

It was a long and difficult linked list, but apparently, it works. Below are some other pages of code in C++, exercises most of the time. I have also put some of my plugins for 3dsmax.

I learned maxscript before learning C++, here are some scripts or plugins I did:

Next, there is some linear algebra and funny matrices:

This is now a script for enciphering and deciphering messages.

Here is an example of enciphered message. If I tell you that the 2 primes are 431 and 743 , with my script above you surely can translate the following message: 62520 172480 147764 226702 42110 58127 123996 256203 196716 181614 299597 181614 241357 187604 32762 17311 309478 29630 301116 153664 113777 14703