Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C++ Builder

Posted on 2003-10-24
2
Medium Priority
?
194 Views
Last Modified: 2010-04-17

I'm a novice.

I want to read two pairs of values from a simple file (that can be positive or negative) to determine which are the lowest and highest. The file is just that, a series of values, however teh first one is an x co-ordinate and the second a y co-ordiante.

I have some code that works for a single value, how do I mod it for two.

points=0;
  maxheight = 0;
  while (file1>>height){
   points++;
   if (height>maxheight)
     maxheight=height;
     }
  file1.close();
    }

This code extracts one value for height and determines the max value. teh file I am looking at detemines heading.

I know this is scandously overpriced in terms of points, but I need help and we're thick in th UK. And yes, it's a college assignment ........

Madoc




0
Comment
Question by:madoc
2 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 9615419
Hi madoc,

so what does you file look like?

<x> <y>
 
or

<x>
<y>
<x>
<y>
<x>
<y>
...

Cheers!
0
 
LVL 19

Accepted Solution

by:
Dexstar earned 1000 total points
ID: 9615462
madoc,

> I have some code that works for a single value, how do I mod it for two.

  #include <limits.h>

  int width;

  points = 0;
  maxheight = INT_MIN;
  maxwidth = INT_MIN;
  minheight = INT_MAX;
  minwidth = INT_MAX;
  while ( (file1>>height) && (file1>>width) )
  {
    points++;
    if ( height > maxheight )
       maxheight = height;

    if ( height < minheight )
       minheight = height;

    if ( width > maxwidth )
       maxwidth = width;

    if ( width < minwidth )
       minwidth = width;
  }
 
  file1.close();


Hope that helps,
Dex*
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Six Sigma Control Plans
Loops Section Overview

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question