#include<iostream> 
using namespace std;
#include<string> 
#include<vector> 
template<class T>

class List
{
public:
    List():head(0),tail(0),theCount(0){}
    virtual~List();
    void insert( T value );
    void append( T value );
    int is_present( T value) const;
    int is_empty( ) const{ return head == 0; }
    int count() const { return theCount; }
    void List_Display();
    T List_getValues()const;
    vector<T> List_getValues_array()const;
    void List_Count() { cout << " Count is : " << theCount << endl;}
    int List_Count1()const { return theCount;}
    template<class T>
    friend int operator== (const T& lhs,const T& rhs );
private:
   class ListCell
   {
   public:
        ListCell( T value, ListCell * cell = 0): val(value),
        next(cell) {}
        T val;
        ListCell * next;
        T getValue() const { return val; }
        void display(ListCell * pt)
        {
	       cout<<" Value is : " << pt->getValue() << endl; 
        }
    };
    ListCell * head;
    ListCell * tail;
    int theCount;
};
template<class T>
List<T> :: ~List()
{
   ListCell * pt = head;
   while(pt)
   {
       ListCell * tmp = pt;
       pt =pt->next;
       delete tmp;
   }
   head = 0;
   tail = 0;
}
template<class T>
void List<T> :: insert(T value ) 
{
   ListCell * pt = new ListCell( value, head );
   if( head==0) tail = pt;
   head = pt;
   theCount++;
}
template<class T>
void List<T> :: append(T value ) 
{
   ListCell * pt = new ListCell( value);
   if( head==0) head = pt;
   else {tail->next = pt;}
   tail = pt;
   pt->next = 0;
   theCount++;
}
template<class T>
int List<T> :: is_present( T value ) const
{
   if(head==0) return 0;
   if(head->val==value) return 1; ListCell * pt = head->next;
   for(;pt != tail; pt = pt->next )
   if(pt->val==value) return 1;

   return 0;
} 
template<class T>
void List<T> :: List_Display()
{
   ListCell * pt = head;
   while(pt!=tail->next)
   {
      cout<<" Value is : " << pt->getValue() << endl;
      pt = pt->next;
   }
}
template<class T>
T List<T> :: List_getValues()const
{
   T value;
   T value_array[100];
   ListCell * pt = head;
   while(pt!=tail->next)
   {
      value += pt->getValue();
      pt = pt->next;
   }
   for(int i=0;i<=theCount;i++){if(pt!=tail->next){value_array[i]=pt->getValue();pt=pt->next;}}
   return value;
   //return value_array;
}
template<class T>
vector<T> List<T> :: List_getValues_array()const
{
   vector<T>val_vect;
   T value_array[100];
   ListCell * pt = head;

   for( int i=0; i<=theCount; i++ )
   {
      if(pt!=tail->next) 
         { 
		   value_array[i] = pt->getValue();
           val_vect.push_back(value_array[i]);
           cout<<" "<< value_array[i];
           pt = pt->next; 
	      }
    }
   //return value_array[0];
   return val_vect;
}




template<class T>
int operator== (const T& lhs,const T& rhs )
{//compare lengths first
   T value1; T value2;
   if( lhs.theCount != rhs.theCount ) 
      return 0;//lengths differ 
   if( lhs.List_getValues()!= rhs.List_getValues() )
      return 0;
   return 1;//if they dont differ , they must match
}

class cat
{ };

int main()
{
   List<string>test;
   List<cat>test1;
   List<int>test2;
   test.List_Count();
   test.append("qw");
   test.List_Count();
   test.insert("yu");test.List_Count();
   test.append("az");test.List_Count();
   test.insert("kim");test.List_Count();
   test.List_Display();

   cout<<'\n';
   test2.List_Count();
   test2.append(786);test2.List_Count();
   test2.append(9000);test2.List_Count();
   test2.List_Display();

   cout<<'\n';
   List<string> test3; 
   test3 = test;
   test3.List_Display();
   if( test3 == test ) cout<< " \n1111 ";
   else cout<<" \n0000 ";

   cout<< test.List_getValues();

   vector<string>t = test.List_getValues_array();
   vector<string>t3 = test3.List_getValues_array();

   cout<<'\n';
   for( int i = 0; i < (test.List_Count1()); i++ ) 
   cout<< t[i]<<" ";
   if( t == t3 ) cout<< " test = test3 ...\n";


   getchar(); return 0;
}

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

C++LANGUAGE
 
basicperson.h
aperson.h
aperson.cpp
ofstream.cpp
 
 
 
 
maxplugins
 
thirddegree.cpp
 
fibonacci.cpp
 
linkedlist.cpp
 
binary1
 
binary2
 
BACKHOME
 
hex1
 
hex2
 
simpleLinkedList
 
determinantmatrix
 
QRdecomposition
 
cryptography