inputting a search array. I tried putting a binary search but I can't get it to work. everything else works up until I put the value I am searching for in the array, then it just crashes.
How it suppose to work: input 2 coordinates with a value each then it calculates the distance between them then it suppose to let user search the coordinates for a value and state if found which coordinate it is at.
Write a C++ program that compares the execution time of the above summation using two different solutions: one that uses loops, and another that uses the closed form approach. Use large values of n for the comparisons, such as, 10^7, 10^8, 10^9, 10^10, 10^11,10^12, 10^13, and 10^14. Provide a comparison table for the execution time in both solutions.Do not worry about the value of the actual sum. Overflow will occur in the sum value rendering it invalid; however, this is not the primary concern of the program. Execution time is the primary concern.
I am trying to do single axis solar tracker with linear actuator /rtc/ UNO. I have already done with feedback sensor.
Now Here I am trying to without feedback. Linear actuator specification: 24v , 3.2mm/sec as speed , 600mm stoke.
Desired angle calculation: tracking start from 7am to 18PM, 11hours Assumed degree: 7AM as -45 deg , 12.30 as 0 degree and 18 pm as 45 degree. static float slope= 0.00227272727273; static float intercept=- 102.272727273;
[Code] ....
How can i put time here. Coding for calculating Ton time and solve above equation. below i posted my code . I need it has to be modified little bit. i need to implement ton time actuator here.
I need function takes desired and actual angle , where actuator try to move to its actual desired position.
Code below in arduino version
Code: double Desire_Degree; unsigned int TS; static float slope= 0.00227272727273; static float intercept=- 102.272727273; static int length; double Actual_Degree;
I'm trying to write a continuous linear linked list. But whenever I run my program and enter an option from my list, my switch statement gets highlighted in green and says "Thread 1: breakpoint 3.1. And then my program just stops. I'm wondering what part of the switch statement I've gotten wrong.
Here's my code. #include <iostream> using namespace std; struct node { int key; node *next; }; node *l; void print(node*list)
How to return a message saying that the value searched for is not found. We had to pull the data in from a .dat, i won't let me attach it as a .dat so I attached it as .txt. I know my it's sloppy. I usually clean up what I can once it is working properly.
#include <iostream> #include <iomanip> #include <fstream> #include <string> using namespace std; int ccnt; int size = 10;
I am trying to implement the linear programming solver. This is the header file of the linear programming solver :
/*! internal Representation of a LP constraint like: (c1 * X1) + (c2 * X2) + ... = K or <= K or >= K Where (ci, Xi) are the pairs in "variables" and K the real "constant". */
[Code] .....
I want to parse all the constraints and bounds as inputs and get the maximum value of the objective function as the output using the above lpsolver header file. I have also attached the sample file below.
I have a linear search algorithm set up to search through an array of class objects it works but the output does not match, when i search for a particluar name in the array the 1st and third values int the array are found but the second value is not found..
below is my code:
int linsearch(string val) { for (int j=0; j <= 3; j++) { if (player[j].getLastName()==val) return j ;
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.
I'm attempting to insert items in my list in sorted order. I have accounted for if head is NULL, and if the item I'm trying to insert is less than head. But the problem occurs when I try to loop through until I find the item that is less than what I want to insert. In the while loop, the program just stops for some reason. Here is my code:
I'm not accessing memory that's not mine, I've made sure that current->next is a real node. I've been troubleshooting this for a couple of days, and I don't understand because it won't even get to the assigning part. It just stops after it goes through the while loop once, it won't go any further, no matter how many items I have in the list.
I currently have a file which allows inputs to record different transistor types. I then have the task of accessing this structure, find a certain manufacturer ID, and print the information about this particular transistor.
My problem is accessing the array to search through.
Here is my code:
Code: #include "stdio.h" const int IDLEN=30; //All constant values defined const int POLARITYLEN=3; const int MAXSTOCKITEMS=10; //First structure defined struct TransistorRec {
[Code]......
The errors I am currently getting are on line 54 'expected primary-expression before "struct"' and on line 60 ' 'maunfacturersID' undeclared'
I am using the gnu glpk library to calculate a linear program for my matrices. Why I get the error message exit code 3 which apparently means "The system cannot find the path specified"?
How to approach this? Not very clear on how hashing works..
Insert the following numbers into a hash table of size 10 (ie an array with 0…9 index position) using a hash function h(k)=(k*71+94)%10 and using Linear Probing.
75, 98, 43,1,-56,93,101,34,23
Insert the following numbers into a hash table of size 10 (ie an array with 0…9 index position) using a hash function h(k)=(k*71+94)%10 and using Chaining.
im tasked with creating a linear search script using functions on a 10 element array. the elements are to be supplied by the user as is the search target.
I understand how to create the array and gather that information from the user as well as howto set a variable for "target", this is what im calling it. Those two parts are simple enough.
I am not fully understanding the calling of an array in a function as a pointer. i semi understand the use of a pointer and howto call a normal pointer in a function. i also understand that an array is nothing more then a "special" pointer with a set of consecutive address blocks for the size of the array.
My first user defined function is simple enough
Code: ReadArray(int A[], int size){ int i; printf("Please enter %d integer numbers separated by spaces: ", size); for (i = 0; i < size; i++) scanf("%d", &A[i]); }
Sso nothing out of the ordinary there. that should be a standard for loop and use of scanf, sadly prof has not covered ssanf or any of the other options so i am stuck using scanf for now. maybe someday down the line in a other program or after this course ill get the chance to learn about better options for gathering data from the user.
I am confused as to my next function:
Code: void SearchArray(int A[], int target, int size);
I've not written any code here yet as im not sure if i should call the A[], or *A for the first type of the function?
If i call *A do i then use something like this for my search:
Code: for (*A = 0; *A < size; *A++) if (*A < target) or use A[] insteadA?
Code: for (i = 0; i < size; i++) if (A[i] = target)
I have a linear buffer coordinate, i am to print onto a screen coordinate.
Say maxy = 20, maxx = 10, bufferx = 20, y, x, Buffer coordinates to screen coordinates: Algorithm: So for each maxx'th of bufferx, y will +1 and x will reset. Mathematical: y = int bufferx / maxx, const double averageIncr = int (maxx+1/maxx) - double (maxx+1/maxx); So the amount of averageIncr in (int bufferx / maxx - float bufferx / maxx) is the screen x coordinate. Then (int bufferx / maxx - float bufferx / maxx) / averageIncr = x
Screen coordinates to buffer coordinates: bufferx, y = 21, x = 10, maxy = 20, maxx = 10,
y * x would be the case if bufferx <= max screen coordinate. There is no max bufferx.
How to find the transition from screen coordinates to buffer coordinates? Also, if the algorithm within a for loop, or that the mathematical way would be slower or not? I rarely touch floating point stuff.
Following is the program I wrote it basically takes 9 inputs and then save them into binary file. then print out the data stored in binary data and find inverse of it then print the inverse out. but its stuck in a loop somewhere.
Code: #include <stdio.h> int main() { int a[3][3],i,j; float determinant=0; int x; FILE *fp = fopen ("file.bin", "wb");
I am trying to make a program like a virtual machine, and therefore I need to have a virtual hard drive. I have it split across four files, each being exactly 67,108,864 bytes (at this point, the files consist of 0x00 throughout the entire file). When I try to write to the beginning of one of the files, I get a "EXC_BAD_ACCESS (code=1, address=0xff)" from Xcode.
My assignment is to write a binary calculator that works with floating point for simple math (+,-,x,/). How to do this. the binary numbers need to be from the user.