Week 11
Week of 11/4

Unit 2

  In Class Homework
Mon Work on PSETs If you are working on the EC problems for Unit 2, see Bubble Sort Practice below
You may also want to see me about how to swap values if you can’t figure it out on your own
Tue Check that practice problems are done
Continue working on PSETs
Continue working on PSETs
Wed Continue working on PSETs
They are due tomorrow
Test will be next Tuesday
Continue working on PSETs
Thu    
Fri Write Runoff together in class
Test next Tuesday, review on Monday
 

programming is easy;

Bubble Sort Practice

  • Write a program bubble.c that sorts an array of integers using bubble sort.
  • Distribution Code:
#include <cs50.h>
#include <stdio.h>

int main(void)
{
    // Get input
    int n = get_int("How many values? ");
    int values[n];
    for (int i = 0; i < n; i++)
    {
        values[i] = get_int("Value %i: ", i);
    }

    // TODO: sort numbers

    // Print sorted values
    for (int i = 0; i < n; i++)
    {
        printf("%i\n", values[i]);
    }
}