You are currently browsing the STARS at MEDAL blog archives for June, 2012


Code from learning session 3

Here’s the code related to what we did in this session:
http://ideone.com/oOW95
http://ideone.com/23FeL
http://ideone.com/KEveU
http://ideone.com/92Fzk
http://ideone.com/syk40
http://ideone.com/BpZqr
http://ideone.com/1Mfeh
http://ideone.com/ubVxy
http://ideone.com/oi04l

I forgot to get to the greatest common divisor, which I still wanted to do, but we can deal with that in the next class.

Assignment 2

This assignment is due by the next learning session on Friday, June 15, 2012. Please complete the programs on ideone.com, and send me the links to your programs via email at martin@martinpelikan.net.

Program A3:
Implement a program that counts the number of all natural numbers up to 10000 (including 10000) that are divisible by at least one of the following three numbers: 5, 8, and 12. For example, numbers 25, 75 and 130 are counted, because they are divisible by 5. Similarly, 16, 32 and 40 are counted because they are divisible by 8. In the end, the program should print out the number of all such natural numbers.

Program A4:
Modify the program A3 to print out also the sum of all the numbers that were counted in the previous problem A3. Therefore, the two outputs should be: (1) the number of all natural numbers up to 10000 divisible by any of 5, 8 and 12, and (2) their sum.

Code from learning session 2

The code I’ve done real-time during the session can be found on the following link:

http://ideone.com/pelikan/session_2

In addition, these are the pieces of code I prepared prior to the session:
http://ideone.com/Eoilq
http://ideone.com/orQlP
http://ideone.com/WStdy
http://ideone.com/IC1hX
http://ideone.com/kIUQr

I will add more code relevant to the use of functions after the next session.

Assignment 1

This assignment is due by the next learning session on Wednesday, June 13, 2012. Please complete the programs on ideone.com, and send me the links to your programs via email at martin@martinpelikan.net.

If you are having problems or questions, please email me so that we can address these before it’s too late.

Program A1:
Implement a simple program that prints out your first name, one letter at a time. That is, you will write a separate “cout” statement to print out every single letter of your name. The output should include the entire name though (you should not put end of lines after each character, the name should look intact).

Program A2:
Implement a program that reads 3 integers from the user (let’s call them i, j, and k). You may assume that the numbers are unique (each number is different from the other two numbers), and that they are all positive. Your program should then check whether any of these numbers is divisible by any other of these numbers, and report all such situations (by printing out each pair of numbers for which this holds). If none of the numbers is divisible by one of the other numbers, there are going to be no outputs.

Examples:

  1. input:
    5 10 15

    output:
    10 is divisible by 5
    15 is divisible by 5
  2. input:
    7 3 21

    output:
    21 is divisible by 7
    21 is divisible by 3
  3. input:
    13 17 3

    output:
  4. input:
    80 16 8

    output:
    80 is divisible by 16
    80 is divisible by 8
    16 is divisible by 8

Code from learning session 1

Here’re the links to the programs we worked on during the learning session 1:

http://ideone.com/MbXAy

http://ideone.com/vjSga
http://ideone.com/QQU6O
http://ideone.com/doC0s
http://ideone.com/5Ea86
http://ideone.com/MbXAy

Additional links to similar codes that I prepared earlier (I already posted about these):
http://ideone.com/5Z7o5
http://ideone.com/CL2TD
http://ideone.com/6GvFA
http://ideone.com/AvtTw
http://ideone.com/JoRau

Added calendar of events

To keep track of our meetings, I created a Google Calendar for the events that involve me (for other STARS events, see the official STARS-2012 schedule). I’ve put the calendar also on this blog. The calendar can be accessed by following the link calendar of events on the right-hand side of this blog (under Pages).

Variables, arithmetic operations and conditions

The following set of programs provides examples for use of variables, arithmetic operations, and conditions. We will look at more examples when we meet:

Program 2: Arithmetic operations, variables
http://ideone.com/5Z7o5

Programs 3-6: Conditions
http://ideone.com/CL2TD
http://ideone.com/6GvFA
http://ideone.com/AvtTw
http://ideone.com/Eoilq

Additional materials for these topics can be found in the books I suggested or online. As we go through more complex topics, we will of course have to revisit these basics and get better at them.

Program 1: I’m alive!

I’ve already put in a few programs for us to start with, here’s the first one. Don’t worry about the post until we start with the program on June 11, 2012 (but of course feel free to look at it already if you want):

http://ideone.com/JoRau

When you click on the link, you should be able to see the first, simple program, similar to the classical “Hello World!” program. The only thing the program does is print out a line with “I’m alive!” on the screen. The output is shown in the page as well, and you can edit and play with the program there yourself.

First step: Create an account on ideone.com

We will complete all or most of the programming projects as well as simple demo programs using an online tool that allows one to execute, store, and share programs. This should make the communication between us much more efficient.

Please, go to the following site and register an account on it, so that you can use the site for your own code. As the primary language, we will use C++ (so you can choose C++ as the default language to work with):

http://ideone.com/

We will use ideone.com to work with programs used by me to teach you main concepts, as well as by you to solve home assignments. The site makes it quite easy to edit the code, run it, and share it. Code can also be assigned to one or more categories, and cloned to create more complex projects in future starting from a previous project.

Welcome to STARS at MEDAL

STARS at MEDAL blog is dedicated to the STARS project at the Missouri Estimation of Distribution Algorithms Laboratory (MEDAL) at the University of Missouri. We will use this blog to post important links throughout the project and keep track of what has been covered, and is required for successful completion of this program.