C++ :: Equations And Intersection Point

Aug 17, 2013

Program which accepts two lines and and determines their intersection point and whether they lie within a circle, also given interactively. I'm racing against time and I've racked my skull to no avail

View 2 Replies


ADVERTISEMENT

C++ :: Finding Intersection Point Between A Plane And A Line

Mar 25, 2013

I'm following this example on finding the intersection point between a plane and a line. (it's about three quarters down) [URL] .....

However this seems to only show how to solve u.

1. I don't understand what u is.
2. How do I find out the intersection point, in terms of (x, y, z)?

View 4 Replies View Related

C :: Intersection Of 2 Arrays

Jan 12, 2015

Code:

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int main() {
int a[10],b[10],c[10],i,j,k,n,m;
printf ("Enter the size of the first vector: ");
scanf ("%d", &n);

[Code] .....

Now, this is what I've been able to do so far, i know it's very basic but I just started learning programming! I tried different methods found on internet but none of them work for me. I want to find the intersection of arrays a & b then put them in array c(or just display them?)

View 6 Replies View Related

C :: Finding Intersection Points Of Two Ellipses

Oct 16, 2014

Today i am going find out solution of two ellipses intersection points using C programming, I solved using geometry equation substitute method but i am not unable to do same thing in C programming.I am talking example as following two ellipses (x^2)/4+y^2=1 , ((x-2)^2)/4+y^2=1

View 11 Replies View Related

C++ :: How To Program Boolean Union And Intersection

Jun 19, 2014

It involves some discrete mathematics. Any code snippet to get me started?

View 3 Replies View Related

C++ :: Find Intersection / Union And Difference Of Two Sets

Feb 17, 2014

The program is to find intersection,union and difference of two sets. The program take the input correctly but after it crashes with the message that some exe is not working...

Code:
#include<iostream>
using namespace std;
void Input(int *A, int*B, int size1, int size2)
//input function {

[Code] ....

View 3 Replies View Related

C++ :: Sweep Line Algorithm Applied To Segment Intersection?

Apr 26, 2013

I need updating binary search three. I am working on implementation of Bentley-Ottoman algorithm for finding intersections of line segments in the plane. Code I designed works properly for all, but certain types of triangles. What is happening is that one intersection inside the triangle is never detected due to a fact that segments which intersect in that point never become neighbors in binary search tree.

class segment{
double x1,y1,x2,y2;
int name;

[Code]....

View 1 Replies View Related

C :: Working With Equations

Nov 19, 2013

I need to find out all the possible equations which are same of a given equation. For eg. a+b+c-d and b+c+a-d are same. So if the user inputs a+b+c-d then the output will be all the possible equations that can be formed from the given equation, viz:

a+c+b-d
c+a+b-d
-d+a+c+b

etc

i.e the program should rearrange the operands and operators in such a way that it should give the same result.

View 5 Replies View Related

C :: How To Change MPI Broadcast Into Asynchronous Point To Point Communication

Jun 26, 2013

I have one code that use MPI broadcast and I want to change it into Asynchronous Point to Point communication. I am newbie in Parallel programming. Looking for implementation of one simple same program in broadcast and P2P ?

View 6 Replies View Related

C :: Calculate The Solutions Of Quadratic Equations

Oct 22, 2014

I have a task to find errors in this long line of code in order to correctly calculate the solutions of quadratic equations.

Code:
int main(int argc, char *argv[]) {
int validInput, solution_type;
double a, b, c, root_1, root_2, q;

/***********************
* Input / Validation
***********************/

/* Check numbers of arguments, and read input */
validInput = (argc = 4);

[Code] ....

Is a section of the code (the first section). And as you can probably guess, it goes on to calculate for a > 0 etc...

I dont really understand what the validinput section is saying? And a, b and c are never defined so Xcode is just saying a,b,c,root1,root2 are uninitialized and I also dont know what means. Do I need to define these values?

Code:
int main(int argc, char *argv[]) {
int validInput, solution_type;
double a, b, c, root_1, root_2, q;

[Code] ......

View 9 Replies View Related

C :: Calculate Equations Just Like A Standard Calculator

Oct 23, 2013

The main point of the program is to calculate equations just like a standard calculator but I wanted to do it myself. I don't understand what the problem is right now but I've managed to create a program that asks for both values but somehow it doesn't want to ask for an operator (*, /, + etc). What's wrong with my code that the terminal skips the scanning part for the operator?

Code:

#include <stdio.h>
int main() {
int value1, value2, answer;
char operator;

[code]....

View 12 Replies View Related

C :: Program That Solves Math Equations

Apr 30, 2013

I wrote a program that solves an equation of two numbers, but in addition to that, I want it to be able to continue to solve longer equations. Ex: ( solves 2 * 4, or 2 * 4 - 5).I want to put this part of the program's result into a variable and go from there. How do I place the result of the calculation into a variable, and where would it go?

Code:

#include <stdio.h>
#include <string.h>
int main(void) {
int a;
scanf("%d", &a);
char s[2];
scanf("%s", s);
int b;
scanf("%d", &b);
}

[code]....

View 4 Replies View Related

C :: Scanning Equations / Functions Into Program

Nov 15, 2014

I have to make a numerical integration program, how I can write my code so that the user is able to write their own function that they want to integrate?

E.g. they would see the message: 'please enter your function' and would be able to write whatever they wanted e.g. 'x +5' then this would then be integrated by the program.

I have already written a program that can integrate a known function but would prefer that the user could choose their own.

View 2 Replies View Related

C++ :: Determine Roots Of Quadratic Equations?

May 23, 2013

I have given following exercise in my cpp book: Determine the roots of quadratic equations

ax^2 + bx + c = 0

using formula

x = -b +(plus-minus) (root)b^2 - 4ac/2a

i don't now how to write such code...

View 6 Replies View Related

C++ :: Solving Linear System Of Equations Using Threads

Dec 14, 2014

I am trying to write a code that solves a system of linear equations such as A*B=C. My system has a dimension equal to 1600. The matrix A cab be separated into 4 sub matrices and each can be handled by a different thread. I tried to solve this using the following code:

int main() {
int count = 0;
//Inputing matrix A
ifstream matrix;
matrix.open("example.txt");

[Code] ....

Although the above code gives the correct answer, the time needs to find the solution is bigger than that needed without using threads.

View 1 Replies View Related

C++ :: Finite Difference Method For Partial Differential Equations?

Nov 10, 2013

Calculated by the explicit scheme. Produces some very large numbers.

task:

[math] U_t = 3 (1,1-0,5 x) U_ {xx} + e ^ t-1 [/ math]
[math] U (0, t) = 0 [/ math]
[math] U (1, t) = 0 [/ math]
[math] U (x, 0) = 0.01 (1-x) x [/ math]

Need to find a solution with accuracy [math] 0.0001 [/ math] on the interval [math] T = 1 / a ^ *, where a ^ * = max a (x, t) [/ math] Plot graphs of functions [math] u (x ^ *, t), u (x, jt ^ *) [/ math] where [math] x ^ * = 0.6, t ^ * = T/10, j = 1,2,4 [/ math]

explicit difference scheme is as follows:

([math] $ u_t ^ {j +1}-u_i ^ j) / tau = 3 (1,1-0,5 x_i) (u_ {i +1} ^ {j}-2u_i ^ j + u_ {i -1} ^ j) / h ^ 2 + e ^ {t_j} +1 $ $ [/ math]

code of the program:

int main ( void ) {
setlocale(LC_ALL, "rus");
int I = 10, J = 30, i, j;
double T = 1.0/ pow(3.3, 0.5), h_x = 1.0/ I, h_t = T/ J, epsilon = h_t + pow(h_x, 2), c;
double **u = new double *[I + 1];
for (i = 0; i <= I; i++) u[i] = new double [J + 1];

[code]....

displays the following:

[URL]

View 2 Replies View Related

Visual C++ :: Pthreads - Solve System Of Equations By Gauss-Jordan Method

Dec 15, 2012

I have a problem: solve the system of equations by the Gauss-Jordan methods with pthreads. I have a big matrix A (for example 2000x2000), so i must solve Ax = b. Before I devide matrix to number of threads and each thread must work only with his peace of matrix.

Code:
#include <iostream>
#include "synchronize.h"
#include <pthread.h>
using namespace std;
typedef struct _ARGS {
int thread_count;
int thread_number;

[Code] .....

I write it on Ubuntu, and when I compile [g++ main.cpp -o main -lpthread -lm] the it works good(for example, if in 1 thread I get time_of_working = 10 sec, on 2 threads time_of_working = 5.4, i.e. about 2 times faster ), if I compile like this [g++ main.cpp -o main -lpthread -lm -O3] it is only 1.2-1.3 times faster.

View 1 Replies View Related

C :: Value Of A Polynomial In A Point

Jan 3, 2015

I don't know why this doesn't work. It doesn't return any errors, but it does the polynomial equation wrong. I tried using "^" instead of "pow" and it still does it wrong. I'm getting results like "-897123897" instead of "3". This is the code:

Code:
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main()
[code]....

View 4 Replies View Related

C++ :: Fixed Point Int Min Value

May 14, 2013

I am reading about positive and negative infinity in c++ and i am trying to implement them in a fixed point math arthimethic implementation

I can see that max of a int will be equal to std::numeric_limits<int>::max();
and min value of the int will be equal to std::numeric_limits<int>::min();
in c++

Here as i am defining the int max and int min manually in my fixed point math implementation, my doubt is
int min = -int max; or int min = -int max -1; ?

View 1 Replies View Related

C :: Floating Point Operations

Mar 16, 2014

Code:
#include<stdio.h>
#include<conio.h>
void main()
{
float i;
i=0.7;

[Code] ....

If i do run the above program in turbo C/C++ complier, it outputs "h". But,if i change the code as i=0.6 and if (i<0.6), it outputs "w". Even if i change it to i=0.8 and if(i<0.8), then also it outputs "w".

View 4 Replies View Related

C :: Floating Point Number - NAN

May 8, 2014

Code:
#include<stdio.h>
#include<conio.h>
float square(float);
void main() { clrscr();
float a,b;
printf("ENter a Number");
scanf("%f",&a);

[Code] ....

In the above program, I am calculating the square of float number. But sometimes the number is entered as NAN and sometimes Output is NAN. What is NAN? I am entering floating point number, then y NAN is entered?

SEE the Image attached for the OUTPUT.

View 2 Replies View Related

C :: Fixed Point From String

Oct 9, 2013

I have been writing a fixed point library the would handle fixed point numbers with an 8:24 whole/fraction ratio. This has been working quite well but since I have a 24 bit fractional part, it should be able to store 2^(-24).

Code:
long long fraction_part = 0;
long long divisor = 1;

while(*string) {
fraction_part *= 10;
fraction_part += *string - '0';
divisor *= 10;
string++;
}

fraction_part <<= 24;
fraction_part /= divisor;

The issue here is that since the smallest possible fraction is 2^(-24) the divisor could end up needing more than 64 bits and so won't work. I'm not quite sure how else I could do this.

View 7 Replies View Related

C :: How To Create Array Who Point To Some Value

Oct 15, 2014

I have to create dynamic array, where each element of it points to some value. I know how to create dynamic array

Code: array_record * record_1 = (array_record*)malloc( (group!/(2!(group!-2)!)) *sizeof(array_record));

But i don't know how i create this case. for example what i want if array elements are:

Code:

index value value
0 01 -> 345
1 02 -> 457
2 03 -> 689
3 21 -> 634

so if i have value somewhere 01 match with 01 in this array it display 345. how i can implement it?

View 1 Replies View Related

C :: Point Of Function Pointers

Sep 27, 2014

I'm wondering about the point of pointers to functions. When is it used?I saw the below example. It doesn't make sense to me. I mean we can easily write code that does the same without having to use pointers.

Code:

#include <stdio.h>
int addInt(int a, int b); // Adds 2 integers
int add5to4(int (*function_pointer)(int, int));
int main(void)
{
int sum;
int (*function_pointer)(int, int);
}

[code]....

View 2 Replies View Related

C++ :: Directx9 3d Point In Ground

Apr 1, 2013

now that I can pick a mesh I want to put it in the ground.So I'm looking for the 3d position of my mouse in the ground.this is my code about picking:

D3DXMATRIX p_matProjection, p_matView, p_matWorld, p_matInverse;
pDevice->GetTransform(D3DTS_PROJECTION,&p_matProjection);
pDevice->GetTransform(D3DTS_VIEW, &p_matView);
pDevice->GetTransform(D3DTS_WORLD, &p_matWorld);
// use the mouse coordinates to get the mouse angle

[code].....

View 3 Replies View Related

C++ :: Point Of NULL In CString

Jul 9, 2014

I dont see any point of NULL in cstring. The code given below just outputs same as it would have done with NULL. My understanding is if size of char array is less than length of char array then null must be manually added?

#include <iostream>
using namespace std;
int main(){
char chr[0];
cin>>chr;//or if you use cin.getline;
cout<<chr<<endl;
return 0;
}

Enter something: hellowwwww
hellowwwww
Segmentation fault (core dumped)

why? for NULL char or something else?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved