I really had a great time with Ken as my teacher and his way of teaching is incredible! I had never been on a class where I feel like the teacher was actually my friend and he helped us a lot through our way in the course.
I highly recommend a flipped class room and even more if you have the opportunity to be with Ken Bauer, he is one of the best teachers that I ever had.
Thanks Ken!
-The admin, Esaú.
PS: Here is the video.
My buddy and I finally acomplish our project for our TC101 class.
Well, basically, our program had to do the following:
“You will create a command-line program that uses two-dimensional arrays or matrices to process images. You cannot simply call graphics libraries to manipulate the images directly but must implement the functions with your own algorithms. The input to each operation is an image (you choose to support any of JPEG, PNG) and the output is the modified image. The idea is to have a final project which shows your mastery of the topics in this course”.
I was really hard to acomplish but Eduardo and I worked together and we made it!
The user is able to type in the name of the file (a picture) and the program will process the image outputting a different file than the first one.
There is a huge code!
It looks like this:
#include <Magick++.h> #include <iostream> #include <cmath> using namespace std; using namespace Magick; void grayscale (string in, string out){ Image image; image.read( in ); int x = image.rows(); int y = image.columns(); Color image_array [x] [y]; Color original; Color graysc; int col; for (int i=0; i < x; i++){ for (int u = 0; u < y; u++){ original = image.pixelColor(u,i); image_array [i][u] = original; col = (original.redQuantum() + original.greenQuantum() + original.blueQuantum()) / 3; graysc.redQuantum(col); graysc.greenQuantum(col); graysc.blueQuantum(col); image_array [i] [u] = graysc; image.pixelColor(u, i, graysc); } } image.write( out ); } void scale(string in, string out){ Image image; image.read( in ); int x = image.rows(); int y = image.columns(); int xf = x/2; int yf = y/2; Image image2( Geometry(yf, xf), Color(MaxRGB, MaxRGB, MaxRGB, 0)); Color image_array [x] [y]; Color image_array2 [xf] [yf]; Color pixel1, pixel2, pixel3, pixel4, pixel5; int red,blue,green; Color newRGB, newRGB2; for (int i=0; i < x; i++){ for (int u = 0; u < y; u++){ pixel1 = image.pixelColor(u,i); image_array [i][u] = pixel1; } } for (int i=0; i < x; i = i+2){ for (int u = 0; u < y; u = u+2){ int x2 = i/2; int y2 = u/2; pixel2 = image_array [i] [u]; pixel3 = image_array [i+1] [u]; pixel4 = image_array [i] [u+1]; pixel5 = image_array [i+1] [u+1]; red = (pixel2.redQuantum() + pixel3.redQuantum() + pixel4.redQuantum() + pixel5.redQuantum())/4; blue = (pixel2.blueQuantum() + pixel3.blueQuantum() + pixel4.blueQuantum() + pixel5.blueQuantum())/4; green = (pixel2.greenQuantum() + pixel3.greenQuantum() + pixel4.greenQuantum() + pixel5.greenQuantum())/4; newRGB.redQuantum(red); newRGB.greenQuantum(green); newRGB.blueQuantum(blue); image_array2 [x2] [y2] = newRGB; } } for (int i=0; i < xf; i++){ for (int u = 0; u < yf; u++){ newRGB2 =image_array2 [i] [u]; image2.pixelColor(u, i, newRGB2); } } image2.write( out ); } int main(int argc,char **argv) { InitializeMagick(*argv); try { string im; string out; int ans; cout << "Write your file name: "; cin >> im; cout<< "Write the name of your output file: "; cin>>out; cout<<"What do you wanna do?"<<endl<<"1. Grayscale."<<endl<<"2. Scale (1/2)."<<endl; cin>>ans; while (ans != 1 && ans != 2){ cout<<"Try again please: "; cin>>ans;} if(ans == 1){ grayscale(im, out);} if (ans == 2){ scale(im, out); } } catch( Exception &error_ ) { cout << "Caught exception: " << error_.what() << endl; return 1; } return 0; //// c++ -O2 -o prog prog.cpp `Magick++-config --cppflags --cxxflags --ldflags --libs` }
There is also a Repository made it in Github and that’s were our teacher is going to check it out.
Any question feel completely free to ask.
Thank you guys for everything.
-The Admin.
]]>
In the first one we had to write a function called superpower that has two parameters of type long and returns a long which is first parameter raised to the power of the second.
For example, superpower (3, 4) would return 81.
And in the second program we wrote a function called stars that has one parameter of type int and prints (the function does not return anything) that many stars on a single line followed by a end-of-line character, so if we call the function with stars (5), the function will print like this:
*****
At first it was hard to write this codes but then, when I looked for help I could notice that actually they were pretty easy and with a few minutes of reading I could understand a little bit more about how the functions work.
You can check the codes at the bottom of this post or in my GitHub account in the Quizzes Repository, it’s up to you!
Here are the codes of my two programs.
SuperPower!
#include <iostream> #include <cmath> using namespace std; long superpower (long a, long b){ long superpower = 0; superpower = pow(a,b); return superpower; } int main (){ cout<< superpower(3,4) <<endl; return 0; }
Stars!
#include <iostream> using namespace std; void stars(int iStars){ for (int i = 1 ; i <= iStars; i++){ cout << "*"; } cout << endl; } int main(){ stars(5); return 0; }
This two concepts are input and output, and it’s what we are going to talk about in this post.
First, their definition:
Output:
Any information that has been processed by and sent out from a computer or similar device is considered output.
Input:
Any information or data that is sent to a computer for processing is considered input. Input or user input is most often sent to the computer using an input device such as a keyboard or mouse.
Header Files:
To do input and output, you will need to load the iostream header file.
Like this:
#include <iostream> // I/O #include <fstream> // file I/O #include <iomanip> // format manipulation #include <string>
Which means that you’re confirming that your program will have the ability to receive and send information and manipulate it as you tell it to do it.
Streams:
There only exist 3 streams, which are:
Cout (terminal output)
Cin (Terminal input)
Cerr (error output) Mosly used for error messages.
Here are some code examples where you can see Cout and Cin:
#include <iostream> using namespace std; int main () { int v1, v2; int sum =0; cout<< "Please introduce the lower bound of the range: "; cin>> v1; cout<< "Please introduce the higher bound of the range: "; cin>> v2; int number =v1; while (number<=v2){ sum= sum+number; number++; } cout<< "The inclusive sum is: "<<sum<<endl; return 0; }
I really hope this post can help to solve your doubts about Input/Output in C++, if you want to know more abot this I will let you the link of a really good page!
Once again, feel free to ask anything and I will be happy to answer.
Have a nice day!
-The Admin.
]]>But you can tell me, what’s the special thing with GitHub? Well, imagine that it is like Facebook but for programmers. YES, you can cheer all your codes with your friends and even ask them for help or work in a team project.
But, how do I submit all my work?
Well, this is really simple!
First we have to login to our GitHub account and create a new Repository which is something like a small blog for specific topics, in this case, my WSQ tasks.
Once you have created a new repository as I show you in the video which is below this post, then all you have to do is to create a new file and put your stuff in it, upload it to GitHub and let everyone sees your codes and your ideas!
That’s awesome right?
You can also share your GitHub via URL as I do in some posts, that will be leading you to get involve with more and more people who likes the same thing that you and maybe ever meet someone and start working together!
Here is the video of how to submit your own stuff!
And of course, here’s the link of my GitHub account where you will be able to find all my work!
Feel free to pass by!
-The Admin.
]]>This two concepts are input and output, and it’s what we are going to talk about in this post.
First, their definition:
Output:
Any information that has been processed by and sent out from a computer or similar device is considered output.
Input:
Any information or data that is sent to a computer for processing is considered input. Input or user input is most often sent to the computer using an input device such as a keyboard or mouse.
Header Files:
To do input and output, you will need to load the iostream header file.
Like this:
#include <iostream> // I/O #include <fstream> // file I/O #include <iomanip> // format manipulation #include <string>
Which means that you’re confirming that your program will have the ability to receive and send information and manipulate it as you tell it to do it.
Streams:
There only exist 3 streams, which are:
Cout (terminal output)
Cin (Terminal input)
Cerr (error output) Mosly used for error messages.
Here are some code examples where you can see Cout and Cin:
#include <iostream> using namespace std; int main () { int v1, v2; int sum =0; cout<< "Please introduce the lower bound of the range: "; cin>> v1; cout<< "Please introduce the higher bound of the range: "; cin>> v2; int number =v1; while (number<=v2){ sum= sum+number; number++; } cout<< "The inclusive sum is: "<<sum<<endl; return 0; }
I really hope this post can help to solve your doubts about Input/Output in C++, if you want to know more abot this I will let you the link of a really good page!
Once again, feel free to ask anything and I will be happy to answer.
Have a nice day!
-The Admin.
]]>But you can tell me, what’s the special thing with GitHub? Well, imagine that it is like Facebook but for programmers. YES, you can cheer all your codes with your friends and even ask them for help or work in a team project.
But, how do I submit all my work?
Well, this is really simple!
First we have to login to our GitHub account and create a new Repository which is something like a small blog for specific topics, in this case, my WSQ tasks.
Once you have created a new repository as I show you in the video which is below this post, then all you have to do is to create a new file and put your stuff in it, upload it to GitHub and let everyone sees your codes and your ideas!
That’s awesome right?
You can also share your GitHub via URL as I do in some posts, that will be leading you to get involve with more and more people who likes the same thing that you and maybe ever meet someone and start working together!
Here is the video of how to submit your own stuff!
And of course, here’s the link of my GitHub account where you will be able to find all my work!
Feel free to pass by!
-The Admin.
]]>In high level programming languages is absolutely the same, there are several conditions that help guiding the user while he is developing an application or a program, the only exception is that we don’t call them as “Rules”, instead, we know them as Code Conventions and of course, every programming language has different conventions to follow, they may look alike in some aspects but believe me when I tell you that the differences can also be huge.
In this mastery we are going to check out the Code conventions of C++. Outstanding the most important aspects of this rules so you can improve your skills programming and of course, following the right way to do it.
Microsoft defines “Coding Conventions” as following:
Coding conventions are suggestions that may help you write in a specific programming language.
Coding conventions can include the following:
The main reason for using a consistent set of coding conventions is to standardize the structure and coding style of a script or set of scripts so that you and others can easily read and understand the code. Using good coding conventions results in precise, readable, and unambiguous source code that is consistent with other language conventions and as intuitive as possible.
We can make a list of the main aspects about the coding conventions, including the most important aspects, such as:
GENERAL RECOMMENDATIONS.
The main goal of the recommendation is to improve readability and thereby the understanding and the maintainability and general quality of the code.
The attempt is to make a guideline, not to force a particular coding style onto individuals.
NAMING CONVENTIONS.
FILES.
STATEMENTS.
Those were some of the most important conventions used for C++ divided by categories. Therefore it is really important to memorize as much as we can so we can improve our programming skills and make our code syntaxes even clearer so everyone with knowledge of the language will be able to understand it without problems.
Here is a page where you will be able to see all the Code Convention of C++ and some really good examples.
]]>