TOTAL beginner need help with task!

I need some serious help was sick for 3 weeks and missed university and now need to somehow figure this task out

Make a program which determines users choosen point N with coordinates x and y (inputed by user )that is a part of this cube:

http://imageshack.us/photo/my-images/528/taskf.jpg/

right now i have this figured out

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#include <conio.h>
void main()
{


cout << "x value? ";   
   cin >> sk1;   
   cout << "y value? ";   
   clrscr();



how do get that the value x and y is more then one number and how do i measure it against N, i have no clue any help appreaciated

Sorry english is also not my 1st language hopefully i made it somewhat clear
Yep, you have a long way to go (as you really don't have much right now):

First you need to a full main() function (int main(), not void main() ) with a real input/output header and some math:
1
2
3
4
5
6
7
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  return 0;
}


Then let's get two inputs; x and y
1
2
3
4
5
double x, y;
cout << "x coordinate: ";
cin >> x;
cout << "y coordinate: ";
cin >> y;


Then you have to determine if you are in the desired region (which is not a cube):
1
2
bool withincircle =  sqrt( x*x + y*y ) < 1; // if distance to the origin is < 1.
bool withinbox = (-1 * abs(x) + 4) > abs(y); // y = m * x + b. If calculated y @ x is > our y, it's in the box. 


Then output if you're in the region:
1
2
3
4
if (withinbox && !withincircle)
  cout << "You are in the region!" << endl;
else
  cout << "You are not in the region" << endl;
Last edited on
dude your a genius, i tryed to do it in a easy way

#include <stdio.h>
#include <iostream.h>
#include <conio.h>
void main()
{
   clrscr();    
   int x,y;   //user input
   int n,a,b;   //program iput
   a=4;
   b=0;
   cout<<"input x value";
   cin>>x;
   cout<<"input x value";
   cin>>y;
   

   if x>a
   cout << "can't be in the cube" << endl;


i got this far in an easy way

will do yours now




Last edited on
You're welcome.

PS. You aren't using DevC++ are you? <iostream.h> and void main() should give compiler errors on any compiler written in the past decade.
Last edited on
its funny but its borland c++, i have no idea why my university uses these things instead of microsoft visual express

and yes we do also sometimes use devc++
Last edited on
its done thanks again!
Topic archived. No new replies allowed.