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

Info icon This preview shows pages 1–6. 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 fin.open("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 }
Image of page 1

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

View Full Document Right Arrow Icon
Sheet1 Page 2 #include <iostream> using namespace std #include <fstream> struct point { int x float weight } int get_user_input()
Image of page 2
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
Image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern