This is my final post, and it’s about my sudoku program
At the beggining, I fount it kind of impossible to finish, because the code scared the s#%t out of me, but it was not at hard as it is.
We just needed a little help of friends and of course the teachers help in order to understand this thing and make it work.
I’m not gonna lie, it took us a lot of time, most of it founding where was the damn problem at the time to compile it, but it was a very nice experience.
So that was it, this might be my last post so I will leave this image down below to remenber that we all are like ninjas, and also because, well sudoku dude.
Ninja banana forever !!!
]]>This is my video for my bonus point !!!!
Continue reading ]]>This is my video for my bonus point !!!!
]]>Data analysis with tools (to be determined which tool)
I don`t really understand what we were ask for in this mastery, so I will leave down below a 50 minute lecture about how to Analyze Data in C++. I've already see half of the video and it has been very helpful.
Link to what programming was for me
Credits:
https://www.youtube.com/watch?v=TDlswNp6mno
Continue reading ]]>
Data analysis with tools (to be determined which tool)
I don`t really understand what we were ask for in this mastery, so I will leave down below a 50 minute lecture about how to Analyze Data in C++. I’ve already see half of the video and it has been very helpful.
Link to what programming was for me
Credits:
https:/
]]>
Visualization of data with tools C++
Views
Create portable and high performance C++ graphical user interfaces (Base Product)
Menus, buttons, text fields, toolbars, tables, trees, spreadsheets, Gantt displays, SCADA displays, custom graphic objects
Views Charts
High performance C++ charts for Views developers
Bar, line, point, area, stair, high-low, stacked, bubble, pie charts, and real-time monitoring, performance analysis
Views Graph Layout
Add diagram displays with automatic graph layout to Views applications
Network topologies, flowcharts, processes, organization charts, call graphs, schematics, hierarchies
Views Maps
High performance map displays for Views developers
Geographic map background, custom data-aware symbols, vector and raster maps
Views Data Access
Easy data connectivity for Views user interface controls
Data-aware controls
DB Link
Portable C++ database connectivity components for Views applications
Database and platform independence
Server
Represent GUI elements and topology as shared in-memory services
Connecting supervision GUI
Credits:
Continue reading ]]>Visualization of data with tools C++
Views
Create portable and high performance C++ graphical user interfaces (Base Product)
Menus, buttons, text fields, toolbars, tables, trees, spreadsheets, Gantt displays, SCADA displays, custom graphic objects
Views Charts
High performance C++ charts for Views developers
Bar, line, point, area, stair, high-low, stacked, bubble, pie charts, and real-time monitoring, performance analysis
Views Graph Layout
Add diagram displays with automatic graph layout to Views applications
Network topologies, flowcharts, processes, organization charts, call graphs, schematics, hierarchies
Views Maps
High performance map displays for Views developers
Geographic map background, custom data-aware symbols, vector and raster maps
Views Data Access
Easy data connectivity for Views user interface controls
Data-aware controls
DB Link
Portable C++ database connectivity components for Views applications
Database and platform independence
Server
Represent GUI elements and topology as shared in-memory services
Connecting supervision GUI
Credits:
]]>Reading and writing of files in C++
A file must be opened before you can read from it or write to it. Either the ofstream or fstreamobject may be used to open a file for writing and ifstream object is used to open a file for reading purpose only.
Following is the standard syntax for open() function, which is a member of fstream, ifstream, and ofstream objects.
#d6d6d6;">void open(const char *filename, ios::openmode mode);
Here, the first argument specifies the name and location of the file to be opened and the second argument of the open() member function defines the mode in which the file should be opened.
Mode Flag | Description |
---|---|
ios::app | Append mode. All output to that file to be appended to the end. |
ios::ate | Open a file for output and move the read/write control to the end of the file. |
ios::in | Open a file for reading. |
ios::out | Open a file for writing. |
ios::trunc | If the file already exists, its contents will be truncated before opening the file. |
You can combine two or more of these values by ORing them together. For example if you want to open a file in write mode and want to truncate it in case it already exists, following will be the syntax:
#d6d6d6;">ofstream outfile; outfile.open("file.dat", ios::out | ios::trunc );
Similar way, you can open a file for reading and writing purpose as follows:
#d6d6d6;">fstream afile; afile.open("file.dat", ios::out | ios::in );
When a C++ program terminates it automatically closes flushes all the streams, release all the allocated memory and close all the opened files. But it is always a good practice that a programmer should close all the opened files before program termination.
Following is the standard syntax for close() function, which is a member of fstream, ifstream, and ofstream objects.
#d6d6d6;">void close();
While doing C++ programming, you write information to a file from your program using the stream insertion operator (ofstream or fstream object instead of the cout object.
You read information from a file into your program using the stream extraction operator (>>) just as you use that operator to input information from the keyboard. The only difference is that you use an ifstream or fstream object instead of the cin object.
Following is the C++ program which opens a file in reading and writing mode. After writing information inputted by the user to a file named afile.dat, the program reads information from the file and outputs it onto the screen:
#d6d6d6;">#include #include using namespace std; int main () { char data[100]; // open a file in write mode. ofstream outfile; outfile.open("afile.dat"); cout "Writing to the file" endl; cout "Enter your name: "; cin.getline(data, 100); // write inputted data into the file. outfile data endl; cout "Enter your age: "; cin >> data; cin.ignore(); // again write inputted data into the file. outfile data endl; // close the opened file. outfile.close(); // open a file in read mode. ifstream infile; infile.open("afile.dat"); cout "Reading from the file" endl; infile >> data; // write the data at the screen. cout data endl; // again read the data from the file and display it. infile >> data; cout data endl; // close the opened file. infile.close(); return 0; }
When the above code is compiled and executed, it produces the following sample input and output:
#d6d6d6;">$./a.out Writing to the file Enter your name: Zara Enter your age: 9 Reading from the file Zara 9
Above examples make use of additional functions from cin object, like getline() function to read the line from outside and ignore() function to ignore the extra characters left by previous read statement.
Credits:
http://www.tutorialspoint.com/cplusplus/cpp_files_streams.htm
Continue reading ]]>Reading and writing of files in C++
A file must be opened before you can read from it or write to it. Either the ofstream or fstreamobject may be used to open a file for writing and ifstream object is used to open a file for reading purpose only.
Following is the standard syntax for open() function, which is a member of fstream, ifstream, and ofstream objects.
#d6d6d6;">void open(const char *filename, ios::openmode mode);
Here, the first argument specifies the name and location of the file to be opened and the second argument of the open() member function defines the mode in which the file should be opened.
Mode Flag | Description |
---|---|
ios::app | Append mode. All output to that file to be appended to the end. |
ios::ate | Open a file for output and move the read/write control to the end of the file. |
ios::in | Open a file for reading. |
ios::out | Open a file for writing. |
ios::trunc | If the file already exists, its contents will be truncated before opening the file. |
You can combine two or more of these values by ORing them together. For example if you want to open a file in write mode and want to truncate it in case it already exists, following will be the syntax:
#d6d6d6;">ofstream outfile; outfile.open("file.dat", ios::out | ios::trunc );
Similar way, you can open a file for reading and writing purpose as follows:
#d6d6d6;">fstream afile; afile.open("file.dat", ios::out | ios::in );
When a C++ program terminates it automatically closes flushes all the streams, release all the allocated memory and close all the opened files. But it is always a good practice that a programmer should close all the opened files before program termination.
Following is the standard syntax for close() function, which is a member of fstream, ifstream, and ofstream objects.
#d6d6d6;">void close();
While doing C++ programming, you write information to a file from your program using the stream insertion operator (ofstream or fstream object instead of the cout object.
You read information from a file into your program using the stream extraction operator (>>) just as you use that operator to input information from the keyboard. The only difference is that you use an ifstream or fstream object instead of the cin object.
Following is the C++ program which opens a file in reading and writing mode. After writing information inputted by the user to a file named afile.dat, the program reads information from the file and outputs it onto the screen:
#d6d6d6;">#include#include using namespace std; int main () { char data[100]; // open a file in write mode. ofstream outfile; outfile.open("afile.dat"); cout "Writing to the file" endl; cout "Enter your name: "; cin.getline(data, 100); // write inputted data into the file. outfile data endl; cout "Enter your age: "; cin >> data; cin.ignore(); // again write inputted data into the file. outfile data endl; // close the opened file. outfile.close(); // open a file in read mode. ifstream infile; infile.open("afile.dat"); cout "Reading from the file" endl; infile >> data; // write the data at the screen. cout data endl; // again read the data from the file and display it. infile >> data; cout data endl; // close the opened file. infile.close(); return 0; }
When the above code is compiled and executed, it produces the following sample input and output:
#d6d6d6;">$./a.out Writing to the file Enter your name: Zara Enter your age: 9 Reading from the file Zara 9
Above examples make use of additional functions from cin object, like getline() function to read the line from outside and ignore() function to ignore the extra characters left by previous read statement.
Credits:
http:/
Validated user input in C++
For this mastery, I found a super useful video that taught me how to make a validation for a user input
Here is also an example code with a validation user input code:
#include
#include
int main(){
bool valid = false;
int input;
while(!valid){
if(std::cin>>input){//this checks whether an integer was entered
if(input 0) valid = true;//then we have to see if this integer is in range
}else std::cin.clear();//some cleaning up
std::cin.ignore(std::numeric_limits::max(), 'n');//empty input stream
if(!valid) std::cout "this input is not validn";
}
std::cout " is between 1 and 5n";
std::cin.get();
return 0;
}
Credits:
Continue reading ]]>Validated user input in C++
For this mastery, I found a super useful video that taught me how to make a validation for a user input
Here is also an example code with a validation user input code:
#include
#include
int main(){
bool valid = false;
int input;
while(!valid){
if(std::cin>>input){//this checks whether an integer was entered
if(input 0) valid = true;//then we have to see if this integer is in range
}else std::cin.clear();//some cleaning up
std::cin.ignore(std::numeric_limits<:streamsize>::max(), 'n');//empty input stream
if(!valid) std::cout "this input is not validn";
}
std::cout " is between 1 and 5n";
std::cin.get();
return 0;
}
Credits:
]]>Creation and use of matrixes in C++ (multi - dimensional arrays)
The simplest form of the multidimensional array is the two-dimensional array. A two-dimensional array is, in essence, a list of one-dimensional arrays. To declare a two-dimensional integer array of size x,y, you would write something as follows:
#d6d6d6;">type arrayName [ x ][ y ];
Where type can be any valid C++ data type and arrayName will be a valid C++ identifier.
A two-dimensional array can be think as a table, which will have x number of rows and y number of columns. A 2-dimensional array a, which contains three rows and four columns can be shown as below:
Thus, every element in array a is identified by an element name of the form a[ i ][ j ], where a is the name of the array, and i and j are the subscripts that uniquely identify each element in a.
Multidimensioned arrays may be initialized by specifying bracketed values for each row. Following is an array with 3 rows and each row have 4 columns.
#d6d6d6;">int a[3][4] = { {0, 1, 2, 3} , /* initializers for row indexed by 0 */ {4, 5, 6, 7} , /* initializers for row indexed by 1 */ {8, 9, 10, 11} /* initializers for row indexed by 2 */ };
The nested braces, which indicate the intended row, are optional. The following initialization is equivalent to previous example:
#d6d6d6;">int a[3][4] = {0,1,2,3,4,5,6,7,8,9,10,11};
An element in 2-dimensional array is accessed by using the subscripts, i.e., row index and column index of the array. For example:
#d6d6d6;">int val = a[2][3];
The above statement will take 4th element from the 3rd row of the array. You can verify it in the above digram.
#d6d6d6;">#include using namespace std; int main () { // an array with 5 rows and 2 columns. int a[5][2] = { {0,0}, {1,2}, {2,4}, {3,6},{4,8}}; // output each array element's value for ( int i = 0; i 5; i++ ) for ( int j = 0; j 2; j++ ) { cout "a[" i "][" j "]: "; cout a[i][j] endl; } return 0; }
When the above code is compiled and executed, it produces the following result:
#d6d6d6;">a[0][0]: 0 a[0][1]: 0 a[1][0]: 1 a[1][1]: 2 a[2][0]: 2 a[2][1]: 4 a[3][0]: 3 a[3][1]: 6 a[4][0]: 4 a[4][1]: 8
As explained above, you can have arrays with any number of dimensions, although it is likely that most of the arrays you create will be of one or two dimensions.
Credits:
http://www.tutorialspoint.com/cplusplus/cpp_multi_dimensional_arrays.htm
Continue reading ]]>Creation and use of matrixes in C++ (multi – dimensional arrays)
The simplest form of the multidimensional array is the two-dimensional array. A two-dimensional array is, in essence, a list of one-dimensional arrays. To declare a two-dimensional integer array of size x,y, you would write something as follows:
#d6d6d6;">type arrayName [ x ][ y ];
Where type can be any valid C++ data type and arrayName will be a valid C++ identifier.
A two-dimensional array can be think as a table, which will have x number of rows and y number of columns. A 2-dimensional array a, which contains three rows and four columns can be shown as below:
Thus, every element in array a is identified by an element name of the form a[ i ][ j ], where a is the name of the array, and i and j are the subscripts that uniquely identify each element in a.
Multidimensioned arrays may be initialized by specifying bracketed values for each row. Following is an array with 3 rows and each row have 4 columns.
#d6d6d6;">int a[3][4] = { {0, 1, 2, 3} , /* initializers for row indexed by 0 */ {4, 5, 6, 7} , /* initializers for row indexed by 1 */ {8, 9, 10, 11} /* initializers for row indexed by 2 */ };
The nested braces, which indicate the intended row, are optional. The following initialization is equivalent to previous example:
#d6d6d6;">int a[3][4] = {0,1,2,3,4,5,6,7,8,9,10,11};
An element in 2-dimensional array is accessed by using the subscripts, i.e., row index and column index of the array. For example:
#d6d6d6;">int val = a[2][3];
The above statement will take 4th element from the 3rd row of the array. You can verify it in the above digram.
#d6d6d6;">#includeusing namespace std; int main () { // an array with 5 rows and 2 columns. int a[5][2] = { {0,0}, {1,2}, {2,4}, {3,6},{4,8}}; // output each array element's value for ( int i = 0; i 5; i++ ) for ( int j = 0; j 2; j++ ) { cout "a[" i "][" j "]: "; cout a[i][j] endl; } return 0; }
When the above code is compiled and executed, it produces the following result:
#d6d6d6;">a[0][0]: 0 a[0][1]: 0 a[1][0]: 1 a[1][1]: 2 a[2][0]: 2 a[2][1]: 4 a[3][0]: 3 a[3][1]: 6 a[4][0]: 4 a[4][1]: 8
As explained above, you can have arrays with any number of dimensions, although it is likely that most of the arrays you create will be of one or two dimensions.
Credits:
http:/
Creation and use of strings in C++
C++ provides following two types of string representations:
The C-style character string.
The string class type introduced with Standard C++.
The standard C++ library provides a string class type that supports all the operations mentioned above, additionally much more functionality. We will study this class in C++ Standard Library but for now let us check following example:
At this point, you may not understand this example because so far we have not discussed Classes and Objects. So can have a look and proceed until you have understanding on Object Oriented Concepts.
#d6d6d6;">#include #include using namespace std; int main () { string str1 = "Hello"; string str2 = "World"; string str3; int len ; // copy str1 into str3 str3 = str1; cout "str3 : " str3 endl; // concatenates str1 and str2 str3 = str1 + str2; cout "str1 + str2 : " str3 endl; // total lenghth of str3 after concatenation len = str3.size(); cout "str3.size() : " len endl; return 0; }
When the above code is compiled and executed, it produces result something as follows:
#d6d6d6;">str3 : Hello str1 + str2 : HelloWorld str3.size() : 10
Credits:
Continue reading ]]>Creation and use of strings in C++
C++ provides following two types of string representations:
The C-style character string.
The string class type introduced with Standard C++.
The standard C++ library provides a string class type that supports all the operations mentioned above, additionally much more functionality. We will study this class in C++ Standard Library but for now let us check following example:
At this point, you may not understand this example because so far we have not discussed Classes and Objects. So can have a look and proceed until you have understanding on Object Oriented Concepts.
#d6d6d6;">#include#include using namespace std; int main () { string str1 = "Hello"; string str2 = "World"; string str3; int len ; // copy str1 into str3 str3 = str1; cout "str3 : " str3 endl; // concatenates str1 and str2 str3 = str1 + str2; cout "str1 + str2 : " str3 endl; // total lenghth of str3 after concatenation len = str3.size(); cout "str3.size() : " len endl; return 0; }
When the above code is compiled and executed, it produces result something as follows:
#d6d6d6;">str3 : Hello str1 + str2 : HelloWorld str3.size() : 10
Credits:
]]>Creation and use of arrays in C++
C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
Instead of declaring individual variables, such as number0, number1, ..., and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent individual variables. A specific element in an array is accessed by an index.
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.
To declare an array in C++, the programmer specifies the type of the elements and the number of elements required by an array as follows:
#d6d6d6;">type arrayName [ arraySize ];
This is called a single-dimension array. The arraySize must be an integer constant greater than zero and type can be any valid C++ data type. For example, to declare a 10-element array called balance of type double, use this statement:
#d6d6d6;">double balance[10];
You can initialize C++ array elements either one by one or using a single statement as follows:
#d6d6d6;">double balance[5] = {1000.0, 2.0, 3.4, 17.0, 50.0};
The number of values between braces { } can not be larger than the number of elements that we declare for the array between square brackets [ ]. Following is an example to assign a single element of the array:
If you omit the size of the array, an array just big enough to hold the initialization is created. Therefore, if you write:
#d6d6d6;">double balance[] = {1000.0, 2.0, 3.4, 17.0, 50.0};
You will create exactly the same array as you did in the previous example.
#d6d6d6;">balance[4] = 50.0;
The above statement assigns element number 5th in the array a value of 50.0. Array with 4th index will be 5th, i.e., last element because all arrays have 0 as the index of their first element which is also called base index. Following is the pictorial representaion of the same array we discussed above:
Credits:
http://www.tutorialspoint.com/cplusplus/cpp_arrays.htm
http://www.cplusplus.com/doc/tutorial/arrays/
Continue reading ]]>
Creation and use of arrays in C++
C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
Instead of declaring individual variables, such as number0, number1, …, and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and …, numbers[99] to represent individual variables. A specific element in an array is accessed by an index.
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.
To declare an array in C++, the programmer specifies the type of the elements and the number of elements required by an array as follows:
#d6d6d6;">type arrayName [ arraySize ];
This is called a single-dimension array. The arraySize must be an integer constant greater than zero and type can be any valid C++ data type. For example, to declare a 10-element array called balance of type double, use this statement:
#d6d6d6;">double balance[10];
You can initialize C++ array elements either one by one or using a single statement as follows:
#d6d6d6;">double balance[5] = {1000.0, 2.0, 3.4, 17.0, 50.0};
The number of values between braces { } can not be larger than the number of elements that we declare for the array between square brackets [ ]. Following is an example to assign a single element of the array:
If you omit the size of the array, an array just big enough to hold the initialization is created. Therefore, if you write:
#d6d6d6;">double balance[] = {1000.0, 2.0, 3.4, 17.0, 50.0};
You will create exactly the same array as you did in the previous example.
#d6d6d6;">balance[4] = 50.0;
The above statement assigns element number 5th in the array a value of 50.0. Array with 4th index will be 5th, i.e., last element because all arrays have 0 as the index of their first element which is also called base index. Following is the pictorial representaion of the same array we discussed above:
Credits:
http:/
http:/
]]>
Creation and use of vectors in C++
Vectors are sequence containers representing arrays that can change in size.
Just like arrays, vectors use contiguous storage locations for their elements, which means that their elements can also be accessed using offsets on regular pointers to its elements, and just as efficiently as in arrays. But unlike arrays, their size can change dynamically, with their storage being handled automatically by the container.
Internally, vectors use a dynamically allocated array to store their elements. This array may need to be reallocated in order to grow in size when new elements are inserted, which implies allocating a new array and moving all elements to it. This is a relatively expensive task in terms of processing time, and thus, vectors do not reallocate each time an element is added to the container.
#a0a0a0; text-align: right; vertical-align: top; min-width: 20px;">
|
#c0c0d0; vertical-align: top; background: #efefff;">
|
#c0c0d0; width: 16px; height: 16px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;">Edit & Run
|
Output:
#e7e7e7;">
The contents of fifth are: 16 2 77 29
|
Credits:
http://www.cplusplus.com/reference/vector/vector/vector/
Continue reading ]]>Creation and use of vectors in C++
Vectors are sequence containers representing arrays that can change in size.
Just like arrays, vectors use contiguous storage locations for their elements, which means that their elements can also be accessed using offsets on regular pointers to its elements, and just as efficiently as in arrays. But unlike arrays, their size can change dynamically, with their storage being handled automatically by the container.
Internally, vectors use a dynamically allocated array to store their elements. This array may need to be reallocated in order to grow in size when new elements are inserted, which implies allocating a new array and moving all elements to it. This is a relatively expensive task in terms of processing time, and thus, vectors do not reallocate each time an element is added to the container.
#a0a0a0; text-align: right; vertical-align: top; min-width: 20px;”>
|
#c0c0d0; vertical-align: top; background: #efefff;”>
|
|
Output:
#e7e7e7;”>
The contents of fifth are: 16 2 77 29
|
Credits:
http:/