Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152
‘#333333’ Articles at TC101 Fall 2015, Page 2
Introduction to Programming Python and C++

Tag Archives: #333333

#Project Advance 2.

So, right now I technically push even forward my programming skills, I mean…using imagemagick is a little bit hard, but today I compile some code and it runs!!!

Marco and I manage to resize the image to one half of its original size, but now we´re struggling with the grayscale functions and stuff, at least we have something to keep working on and we feel positive about the results in our final project.

We find some useful functions in the following pages:

http://www.imagemagick.org/script/perl-magick.php

http://www.imagemagick.org/Magick++/Color.html#ColorGray

 <Magick++.h> 
<iostream>
using namespace std;
using namespace Magick;

void newline(){
  cout<<endl;
}

int main(int argc,char **argv)
{
  InitializeMagick(*argv);
  try{
  int x;
  cout<<"Hi, Im a manipulator of images "<<endl;
  newline();
  cout<<"What do you want to do? (press the number in your keyboard) "<<endl;
  newline();
  cout<<"1. Rezise the image to one half of its original size"<<endl;
  cout<<"2. Switch to black and white"<<endl;
  newline();
  cin>>x;
 
  if(x==1){
     newline();
     cout<<"Alright, now introduce the name of the file with its extension; example: new.jpg"<<endl; 
     newline();
     Image image;
     string img;
     cin>>img;
     image.read(img);
     image.minify();
     image.write("resized.jpg");
 }
  if(x==2){
     newline();
     cout<<"Alright, now introduce the name of the file with its extension; example: new.jpg"<<endl; 
     newline();
     Image image;
     string img2;
     cin>>img2;
     image.read(img2);
     image.quantize(colorspace.gray);
     image.write("blackandwhite.jpg");
 }      
 }
  catch( Exception &error_ )
    {
      cout << "Caught exception: " << error_.what() << endl;
      return 1;
    }
  return 0;
}

The first option is the only one that works, we are going to keep working with the colors.

See you later!

#WSQ13

This wsq was easier than i thought, first I search hoe to use the babylonian method in youtube, so I found these two videos about it:

https://www.youtube.com/watch?v=jTWxFGmWoZg

https://www.youtube.com/watch?v=sZmz7znP6x0

After I analyze the video in detail I finally figure it out how to make a functional .cpp programm in any editor.

Babylonians were freaking smart! in school, teachers never taught me how to calculate the sqrt of a number without a machine, but now…I totally get it!

Here´s my code:

 <iostream>
using namespace std;

double babylonian(double number) {
 double failure= 0.00001;
 double x= number;
 while((x - number/x) > failure) {
 x = (x + number/x)/2;
 cout<<"The intermediate result is " << x <<endl;
 }
 return x;
}

void newline(){
  cout<<endl;
}

int main() {
 double num;
 cout<<"Hi, I´m a calculator of the square root of a number using the babylonian method"<<endl;
 newline();
 cout<<"Introduce the number "<<endl;
 newline();
 cin>>num;
 double result = babylonian(num);
 cout<<"The square root of "<<num<<" equals to "<<result<<endl;

 return 0;
}

Here´s my code on github:

https://github.com/everibarra/TC101-C-/blob/master/wsq13.cpp

#WSQ12

This wsq was pretty easy, I mean, by following the Euclidean Algorithm you can easily know the greatest common divisor between two values

Here´s a video that help me out when I was trying to understand how to use the principles of Euclid.

https://www.youtube.com/watch?v=JUzYl1TYMcU

Also, I need to mention that I receive some more help, because I search for similar codes in the web, and here´s what I found to complete my task.

https://github.com/carolinarmtz/TC1017/blob/master/WSQ12.cpp

And here´s my code:

 
using namespace std;

void newline(){
  coutendl;
}

int common(int first, int second)
{
	if (first==second)
	{
		return first;
	}
	else if (first>second)
	{
		return common(first-second, second);
	}
	else
	{
		return common(first, second-first);
	}
}

int main ()
{
	int x,y;
  cout"Hello, I´m a calculator of the greatest common divisor from two numbers. "endl;
  newline();
  cout"Enter the first number."endl;
  newline();
	cin>>x;
  newline();
  cout"Enter the second number. "endl;
  newline();
  cin>>y;
  newline();
	cout"The greatest common divisor from "x" and "y" is "common(x,y)endl;
	return 0;
}

Topic masterie 23

Here is my video tutorial for the topic masterie 23

link: https://www.youtube.com/watch?v=eK0XawqvTpQ&feature=youtu.be

 

Topic masterie 9

Here is my video tutorial for the topic masterie 9

link: https://www.youtube.com/watch?v=uRmR8yrpwZo&feature=youtu.be

 

Topic masterie 19 and 20

Here is my video tutorial for the masteries 19 and 20

link: https://www.youtube.com/watch?v=U9rBQM-cGC8&feature=youtu.be

 

#WSQ11

First of all, this was a difficult WSQ, I receive a lot of help from Marco Patiño, but I think I just do it right, so thanks Marco!!!

 
 
 #include "BigIntegerLibrary.hh"
  using namespace std;
   bool is_palindrome(BigInteger n) {
   string s = bigIntegerToString (n);
    reverse (s.begin(), s.end());
     BigInteger bi = stringToBigInteger (s);
      if (n == bi) {
      return true;
       }
        else {
        return false;
        } }
         BigInteger apply196(BigInteger n) {
         string s2 = bigIntegerToString (n);
         reverse (s2.begin(), s2.end());
         BigInteger bi = stringToBigInteger (s2);
         n = n + bi; return n;
         }

         int main() {
         int lb;
         int up;
         int np = 0;
         int nl = 0;
          int l = 0;
           BigInteger bn;
           cout  "Write the lower bound: ";
           cin >> lb;
           cout  "Write the upper bound: ";
           cin >> ub;
            cout  endl;
            for (int i=lb; iub; i++) {
            if(is_palindrome(i)==true) {
            cout  "This number is a natural palindrome"  endl; np++;
            }

            else {
            bn = apply196 (i);
            for(int j=1; j30; j++) {
            if(is_palindrome (bn)==true) {
            cout  "This is a non-Lychrel number"endl;
            nl++;
            break;
            }

            else {
             bn = apply196 (bn);
              } }

               if (is_palindrome(bn) == false){
                cout"This is a Lychrel number"endl; l++; coutendl;
                 } } }

                 cout  endl;
                 cout  "Analysis Report: "  endl;
                 cout  endl;
                 cout  "Number of Values Analyzed: "  (ub-lb) + 1  endl;
                 cout  "Number of Natural Palindromes: "  np  endl;
                 cout  "Number of Non-Lychrel Numbers: "  nl  endl;
                 cout  "Number of Lychrel Numbers: "  l  endl; return 0; }

#Quiz08

This was a difficult quiz for me, at first I didn´t know how to use arrays so I decide to use vectors, in the end..IT WORKS!!!!

 <iostream>
<vector>
using namespace std;

void newline(){
  cout<<endl;
}

double sumsquares_list (vector<double> vector){
  double a = vector.size();
  double sum=0;
  for(double i=0; i<a; i++){
    sum=sum+(vector[i]*vector[i]);
  }
  return sum;
}

int main (){
  double x;
  vector<double>vector (0, 4); //You assign a size for your vector.
  cout<<"Hi, I´m a calculator of the addition of squares of the numbers you´ll give me "<<endl;
  newline();
  cout<<"introduce the number (to stop introducing numbers write-->-42)"<<endl;
  newline();
  cin>>x;
  newline();
  while(x!=-42){
    newline();
    cout<<"introduce the next number "<<endl;
    newline();
  vector.push_back(x); //You´re increasing the size of the vector
  cin>>x;
  }
  cout<<"The result equals to "<<sumsquares_list(vector)<<endl;
  return 0;
}

 Here´s my code

https://github.com/everibarra/TC101-C-/blob/master/Q8.cpp

WSQ10! Lists

Same thing but with hashtags…

Now I think I actually ahve to give credit to my friend Miguel  Angel Cárdenas, he took the time to explain me what the heck were vectore and how they worked. I read the book but he explained it so much better.

Anyways here is my code in github:

https://github.com/VanessaBaeza17/Lists/blob/master/CODE

 

Hope it helps you.

Can’t upload image, sorry 🙁

++

 

avance

 <iostream>

<math.h>

using namespace std;

 

int sumsquares_list(int array1[]){

 

for (int i=0; i<5; i++){

int sum=0;

int square=0;

int array1[i];

square=(array1[i]*array1[i]);

}

return square;

}

 

int main(){

int array1[5];

for (int i=0; i<5; i++)

    {

        cout<<"Introduce the numerical value "<<(i+1)<<" : "<<endl;

        cin>>array1[i];

    }

 

cout<<"The result equals to "<<sumsquares_list(square)<<endl;

 

return 0;

}

 

What should you work on?

Week #12 and more partial exams for you.

For this week's readings:
C++ (TC1017) should either be looking at support for your project, ImageMagick C++ libraries are a good start.
Python (TC1014) should be finishing chapter 11 (Dictionaries).