hmwk13 - Hmwk#13 by Dustin Hajiali #include ...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 Hmwk#13 by Dustin Hajiali #include <iostream> using namespace std #include <fstream> struct point { int x int y } int get_user_input() //function to return input of user int main() { point points[50] //declare an array of 50 points ifstream fin //variable to read in file int current_point //variable to help read in a point int current_index = 0 //index counter for array"pairsofints.txt") //open file while(!fin.eof()) //loop over entire file while setting the array { fin >> current_point //read x points[current_index].x = current_point //set x fin >> current_point //read y points[current_index].y = current_point //set y current_index++ //move to next array element } int xcoord = get_user_input() //get x coord from user for(int i=0 i<current_index { if(xcoord == points[i].x) //found a match for x coord { cout << xcoord << ' ' << points[i].y << endl //print out corresponding y coord } } system("PAUSE") return 0 } int get_user_input() { int temp cout << "Type in an integer: " cin >> temp return temp }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/03/2008 for the course CSCI 1300 taught by Professor Lewis,clay during the Fall '08 term at Colorado.

Page1 / 6

hmwk13 - Hmwk#13 by Dustin Hajiali #include ...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online