Posts

Showing posts from December, 2017

Day 23 Nov 16

Image
For homework we had to create a code that could measure which way the wind was blowing. This code prints the percent of wind blowing in each direction, This is the screenshot for the first question. It  prints out the percentage of wind in each direction This is the code for problems 2 and 3, it prints out each direction if they have the same amount of values in the grid, and it also prints out  and it also prints out if there's a possible change of a cyclone if every direction has a value more than zero Here's a screenshot of problem 4 creating a grid of symbols 

Day 22 Nov 14

Image
For homework we had to modify the hand recognition code to read the knowns from a data file, create an array of unknowns from user input, point to the known value with the smallest difference, and print it all out. Here's the code #include <iostream> #include <cmath> #include <fstream> //#define FILENAME "known.txt" using namespace std; int main(void) { double known[5]; ifstream myfile ("known.txt");   if (myfile.is_open())   {     int k;     for(k=0;k<=4;k++) { myfile>>known[k]; }     myfile.close();   } //Declare and initialize variables. //double unknown[5]={5.4,7.2,7.9,7.4,5.1}; double unknown[5]; //double known[5]={6.2,7.0,8.0,7.4,5.8}; cout<<"enter 5 unknown values"<<endl; int k; for(k=0;k<=4;k++) { cin>>unknown[k]; } double distance(double hand_1[5],double hand_2[5]); double comp(double hand_1[5],double hand_2[5]); // Compute and print ...

Day 21 Nov 9

Image
For the homework I had to create a quick sort function, and then use a quicksort function in a linked list. Here's a screenshot of both parts of the homework: Just the quick list part #include <stdio.h> #include <stdlib.h> //void quicksort(int[], int, int); //int partition( int[], int, int); int partition(int a[], int p, int r) { int i,j, pivot, temp; pivot = a[p]; i = p; j = r; while(1) { while(a[i] < pivot && a[i] != pivot) i++; while(a[j] > pivot && a[j] != pivot) j--; if (i <j) { temp = a[i]; a[i] = a[j]; a[j] = temp; } else { return j; } } } void quicksort(int a[], int p, int r) { if (p < r) { int q; q = partition(a, p ,r); quicksort(a,p,q); quicksort(a, q+1, r); } } int main(void) { struct sort; int a[]= {25, 52, 37, 63, 14, 17, 8, 6}; int i; quicksort( a, 0, 7); printf("Sorted array is: "); for(i=0; i<8; ++i) printf(" %d", a[i]); return 0; } ...

Day 20 Nov

For lab today we used interrupters to instantly change the color of the LED.