Progaram Calculating distance points C++

To determine the location of a point on the plane required the initial benchmark. Initial benchmark is made of two number lines that intersect riel perpendicular at the null point, which is a flat (horizontal) and the other upright (vertical). A horizontal line called the X-axis, and a vertical line called the axis Y. Two mutually perpendicular axes is called a Cartesian coordinate system perpendicular or simply coordinate Kartesius.dalam times inni case will make sustu example program that is associated with point atupun cartesian coordinates of two points, we suppose to calculate the distance from the coordinates of two points A ( x1, y1) and B (x2, y2) and this is the shape of his program by using Overloding in C + +;

    # include
    # include

    class count {
         friend ostream & operator <<(ostream &, & count);
         friend istream & operator>> (istream &, & count);

    public:
         count ();
         hitung_jarak void () {distance = ((Y2-Y1) * (Y2-Y1) - (X2-X1) * (X2-X1));}

    private:
         float X1, X2, Y1, Y2, distance;
         };

    count:: count () {
                court <
        court <<"Progaram Calculating distance points C++" <
        court <
        }

    istream & operator>> (istream & ins, & mlebu count) {
         court <<"Enter the point X1 =";
         in>> mlebu.X1;
         court <<"Enter the point X2 =";
         in>> mlebu.X2;
         court <<"Enter the point Y1 =";
         in>> mlebu.Y1;
         court <<"Enter the point Y2 =";
         in>> mlebu.Y2;
         return in;
         }

    ostream & operator <<(ostream & out, count & metu) {
         court <
         court <<"Show Total distance =" <<
         return out;
         }

    main () {
    count x;
    cin>> x;
    x.hitung_jarak ();
    court <

    getch ();
    return 0;
    }


Program ARRAY 1 AND 2 DIMENSIONS C++

Array 2 Dimensional much in use to create a matrix or table data, while the one-dimensional Array in use to make the results or data that berkoordinat X only. In this post two-dimensional array in use to accommodate the values ​​of a component of mathematical equations. While one-dimensional Array used to hold the result or the value of the equation.

    # Include
    # Include

    using namespace std;

    class xyz {/ / declaring class xyz
      public: / /deklaration function xyz, enter, process and exit
         xyz ();
         void enter ();
         void process ();
         void exit ();
     
      private: / / declaring variables a, b and x, y, z
         float a [3] [3];
         float b [3];
         float x, y, z;
         };

    xyz:: xyz () {/ / pendeskripsian function xyz
       court <
       court <<"Looking for Value x, y, z from Equation 3 \ n \ n";
       }

    void xyz:: get () {/ / entry function pendeskripsian
       for (int i = 0; i <3; i + +) {
       court <<"Equal to" <<<":"<< endl;
       court <<"component x:";
       cin>> a [i] [0]; / / insert the value x of an equation
        court <<"y components:";
        cin>> a [i] [1]; / / insert the value y of an equation
        court <<"z components:";
        cin>> a [i] [2]; / / insert the value z of an equation
        court <<"result:";
        cin>> b [i]; / / insert the equation from an equation
        court <
        }
         / / Display the equation
       court <<"\ nPersamaaan:" <
       for (int i = 0; i <3; i + +) {
       court <<<"x +" <<<"y +" <<<"z =" <<
       }

    void xyz:: process () {/ / declaring the function of the process
       for (int i = 1; i> 0; i -) {/ / loop starts from i = 1 until i> 0
         for (int j = 0; j <= 2; j + +) {
           a [i] [j] = a [i] [j] - a [i-1] [j]; / / scoring a
           }
        }

       for (int i = 2; i> 1; i -) {/ / loop starts from i = 2 to i> 1
         for (int j = 0; j <= 2; j + +) {
           a [i] [j] = a [i] [j] - a [i-2] [j];
           }
         }

       for (int i = 2; i> 1; i -) {/ / loop starts from i = 2 to i> 1
         for (int j = 0; j <= 2; j + +) {
           a [i] [j] = a [i] [j] - (2 * a [i-1] [j]);
           }
        }

       b [1] = b [1] - b [0]; / / assignment b
       b [2] = b [2] - b [0];
       b [2] = b [2] - (2 * b [1]);
    
       z = b [2] / a [2] [2]; / / assignment to the variable z
       y = b [1] - (a [1] [2] * z); / / assignment to the variable y
       x = b [0] - (a [0] [1] * y) - (a [0] [2] * z); / / assignment to the variables x
       }

    void xyz:: exit () {/ / exit function pendeskripsian
       court <
       court <<"The value of x =" <<
       court <<"The value y =" <<
       court <<"The value of z =" <<
       court <<
       }

    int main (int argc, char * argv [])
    {
      xyz a;
      a.masuk ();
      a.proses ();
      a.keluar ();

    system ("PAUSE");
    return EXIT_SUCCESS;
    }


Program encrypt and Description C++

Encryption is a process that changes a code which can be understood to be a code that can not be understood (illegible). Encryption can be interpreted as a code or cipher. A cipher using an algorithm that can encode all data streams (stream) bits of a message into an incomprehensible cryptogram (unintelligible). Because cipher technique is a system that has been prepared for the automation, then the technique used in computer and network security systems.

While the description is a process to return the results of a cipher to the code beginning or the beginning of the data entered.

Algorithm.
• Encryption
   Print encryption algorithm
   Declaration:
     plain, cipher: string
     key, i: Integer

   Description:
      read (key, plain)
      for i = 0 to strlen (plain) do
             ciphers [i] <= (plain [i] + key) mod 128;
             end for
      write (cipher)

• Description
    Print a description of the algorithm
    Declaration:
      ciphers, text: string
      key, i: Integer

    Description:
      read (key, cipher)
      for i = 0 to strlen (cipher) do
             text [i] <= (cipher [i] - key) mod 128;
             end for
     write (text)
Program And Description In C + +.

    # Include
    # Include


    using namespace std;
    cryptography class {
        friend istream & operator>> (istream &, cryptography &);
        friend ostream & operator <<(ostream &, cryptography &);
                
      public:
          cryptography ();
          void encryption ();
          void description ();
     
      private:
          char plain [100], cipher [100], text [26];
          int key;
          };
                 
    cryptography:: cryptography () {
                 court <<"Program encrypt and Description C++ \ n \ n";
         court <
         }
                 
    istream & operator>> (istream & ins, cryptography & mlebu) {
         court <<"Enter key:";
         in>> mlebu.key;
         court <<"Enter character:";
         in>> mlebu.plain;
         return in;
         }
         
    void cryptography: encryption () {
      for (int i = 0; i
         ciphers [i] = (plain [i] + key)% 128;}
         court <<
         }
        
    void cryptography:: description () {
       for (int i = 0; i
         text [i] = (cipher [i]-key)% 128;}
         }
        
    ostream & operator <<(ostream & out, cryptography & metu) {
        out <<"the result of encryption:";
        for (int i = 0; i
           out <
           }
           out <
           out <<"the description:";
           for (int j = 0; j
              court <
              }
          out <<
          return out;
          }
            
             
    int main (int argc, char * argv [])
    {
      cryptography x;
      cin>> x;
      x.enkripsi ();
      x.deskripsi ();
      court <
       
      system ("PAUSE");
      return EXIT_SUCCESS;
    }


Program Geometry C++

A sequence U1, U2, U3, .... called geometric sequence if the sequence comparison of the two tribes are fixed. Value of the fixed ratio is called the ratio. a + ar ² + ....... + Arn-1 is called a geometric series with a composition as follows:

a = initial rate
r = ratio
n = many tribes
Formula to find the nth are as follows:

Formula to find the number of n terms is as follows:

• Algorithm Print Geometric Series
    Print geometric algorithms
    Declaration:
      a, b, n, i: Integer
      x []: Array of Integer

    Description:
       read (a, b, n)
       x [1] <= 1
       x [2] <= a * b
       x [3] <= a * b * b
           for i = 4 to n do
           x [i] <= x [2] * [xi-1]
          end for
              for i = 1 to n do
              write (x [i])
             end for

• Counting algorithm of the n
      The algorithm to calculate nth
    Declaration:
      a, b, n, un, i, r: integer

    Description:
       read (a, b, n)
       r <= 1for i = 1 to (n-1) do
       r <= r * b
         end for
         un <= a * r
         write un

• Algorithm Counting all the tribes
      Algorithms add up all the Tribes
      Declaration:
         read (n)
         number, i, n: Integer
         x [ ] : Array of Integer

     Description:
         number <= 0
            for i = 1 to n do
            sum <= sum + x [i]
            end for
        write (number)
Geometric Series Program
    # Include
    # Include

    using namespace std;
    geometry class {
        friend istream & operator>> (istream &, & geometry);
        friend ostream & operator <<(ostream &, & geometry);

    public:
         geometry ();
         void print ();

    private:
         int x [100];
         int a, b, n, un, sn;
         int count;
         };

    istream & operator>> (istream & mlebu, geometry & s) {
           court <<"Enter Interest First:"; mlebu>> S.A;
           court <<"Enter r:"; mlebu>> s.b; court <
           court <<"Enter the Number of Interest:"; mlebu>> sn; court <
           mlebu return;
           }
    
    ostream & operator <<(ostream & metu, geometry & v) {
           metu <<"Interest First:" <<
           metu <<"r:" <<
           metu <<"Number of Interest:" <<
           metu <<"Geometric Series:";
           for (int i = 0; i
             metu <<<",";}
             metu <
             metu <<"Total All Runs:" <<
             return metu;
             court <
                      
    geometry: geometry () {
                court <<"runni" <
        court <
        }
       
    void geometry:: print () {
         x [0] = a;
         x [1] = a * b;
         x [2] = a * b * b;
         for (int i = 2; i
            x [i] = x [1] * x [i-1];}
            number = 0;
               for (int i = 0; i
                sum = sum + x [i];}
                }
              
    int main (int argc, char * argv [])
    {
     geometry x;
     cin>> x;
     x.cetak ();
     court <
     court <

    system ("PAUSE");
    return EXIT_SUCCESS;
    }


Program Fibonaci C++

First let's look more closely at what is on the Fibonacci numbers. Fibonacci sequence is as follows:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
This sequence leads to a certain ratio is constant and that does not make sense, he represents a number that does not end, the sequence of decimal numbers that can not be expected that can not be expressed appropriately or in words .. please understand and be understood. This program may be a bit can help.

    # include
    # include

    class array {
        friend ostream & operator <<(ostream &, array &);
        friend istream & operator>> (istream &, array &);

    public:
        series ();
        void yield () {
          court <<"Fibonacci Numbers <" <<<": \ n0, 1";
          f1 = 0; f2 = 1;
          while (true) {
           f3 = f2 + f1;
           if (f3> limit) break;
           <<","<< int f3;
           f1 = f2;
           f2 = f3;
           };}

    private:
        long boundary, f1, f2, f3;
        };

    sequence:: sequence () {
        court <<"Program Fibonaci C++" <
        court <
        }

    istream & operator>> (istream & ins, series & entry) {
        court <<"Enter a positive number:";
        in>> masuk.batas;
        return in;
        }

    ostream & operator <<(ostream & out, the series & metu) {
        return out;
        }

    main () {
    array x;
    cin>> x;
    x.hasil ();
    court <

    getch ();
    return 0;
    }


Twitter Delicious Facebook Digg Favorites More