checking integer or double, and a little problem

Pages: 12
You are comparing a double to an unknown type.

You still didn't tell me the whole error, but I worked it out anyway. The error had a symbol on the end of it. The symbol is "<".

The "unknown type" is "min". You need to make it a known type. Currently, in your code, min does not exist. You have not created it. You must create it.
Last edited on

That initializes the first min value as min, isnt it?
Nevertheless i made it like it was
double min; max;
Ok it works now.But does it go through all the integers and double points in the triangle


P.s.In fact it works but it goes only through x, when i enter c=3.5 8=9 y stays always 4, while x shows 4,5,6,7,8.Do you have an idea?
Last edited on
std::numeric_limits<int>::min();
That initializes the first min value as min, isnt it?


No. That is a function that returns the minimum integer value.

You need this. Note that you set the initital value of min to the highest possible value, and the initial value of max to the lowest possible value.

1
2
int max= std::numeric_limits<int>::min();
int min = std::numeric_limits<int>::max();


It does not go through all the double points in the rectangle. You said you wanted to do the integer points. There are billions and billions and billions of double points inside any rectangle. Mathematically, there is an infinity of points inside any rectangle.
Last edited on
No no i wanst clear enough.I asked if it checks all points and picks up only the integers, and yes it does.But when i enter a=3.6 b=9 c=4.5 d=9 for example shows for x - 4,5,6,7,8 but for y only 5.
In the last code you showed us, you never changed the value of y. Your loops were wrong. You said this:

1
2
3
for(int x=ceil(a); x<=b; x++ )
{
  for(int x=ceil(c); x<=d; x++ )


Have you fixed that so that y is changed each time the second for loop is processed?

yes it is
Last edited on
You did exactly what I said not to do. I said to do this:

You need this. Note that you set the initital value of min to the highest possible value, and the initial value of max to the lowest possible value.

1
2
int max= std::numeric_limits<int>::min();
int min = std::numeric_limits<int>::max();


You did this:

1
2
 int max= std::numeric_limits<int>::max);
int min = std::numeric_limits<int>::min(); 


I even said:
Note that you set the initital value of min to the highest possible value, and the initial value of max to the lowest possible value.


You did exactly, exactly the opposite of what I said to do.
Last edited on
sry i dint understood correctly.
Ok now it seems that everything is done and it works.Thank you very very much.Now i have to do one more thing-to make a dinner for the kids and to light up a cigarette(finaly)
Thank you very very much!
Last edited on
Topic archived. No new replies allowed.
Pages: 12