C++ :: Find The Most Isolated Feature On Map
Aug 25, 2013
Consider a map that has the following properties;
- the map is two dimensional
- the map is perfectly square with dimensions 10000000x10000000
- the map has an associated set of many features
- the map does not "wrap around"
Each feature on the map is described by a 2D coordinate in the range (0, 0) to (10000000, 10000000).
Find the most isolated feature on the map, where the "most isolated feature" is the feature that is furthest (largest Euclidean distance) from any other feature. Because the map does not "wrap around", this should be a direct distance across the map.
<----10000000---->
--------------- -
| A | |
| | |
| | 10000000
| | |
| B C | |
| E D | |
--------------- -
In the example above, A is the most isolated feature on the square map with edge length 10000000. Write a program that reads in many features from standard input, and outputs the name of the most isolated feature to standard output. The format of the input is the feature name, x coordinate and y coordinate separated by spaces.
Each feature is on a new line. There may be any number of features between 1 and 100000. The program should be fast, so the algorithm must be better than O(n^2).
Any of the following languages are fine - C++, Python (>=2.5), C#, Java. The program shouldn't require any third-party libraries other than the chosen language's standard libraries, and should be compilable and runnable on a modern Windows or Linux development environment of your choice (e.g. MS Visual Studio, gcc, Eclipse etc). You should submit your program source code and any necessary makefiles or project files required for compilation. If you write the code in C++, using C++11 features is fine.
View 1 Replies
ADVERTISEMENT
Nov 5, 2013
I have designed a vc++ dll for a controller. I want to add usb plug and play feature inside the dll. I searched on line and came to know:
"If the project is an unmanaged C++ DLL project, then I can only create windows in an unmanaged way, i.e. the usual Win32 API way, such as adding a new dialog box as a resource, or simply using RegisterClassEx() and CreateWindowEx() to create the window yourself, then pump messages for those windows using GetMessage(), TranslateMessage() and DispatchMessage()."
how to use this concept.
I have created a separate application (in delphi 2007) that load this Dll. But I want to add this Plug and Play feature inside me dll.
View 11 Replies
View Related
Mar 11, 2013
I need to find S and how did you find S in N is 4
#include <iostream>
int main () {
int n,i,s;
cout<<"Put the number of n"<<endl;
cin>>n;
s=0
for (i=1;i<=n;i++)
s=s+i
cout<<"S is<<s<<endl;
return 0
}
View 8 Replies
View Related
Aug 20, 2013
I'm a beginner in C and system programming. I need to use multiple process and POSIX shared memory to find all primes between 0 and 100. My code compiles, but the result is not correct, it shows all the multiples of 3 as primes.My instructor also mentioned that the multi-process portion will fork() the appropriate number of child processes. The parent process will create a POSIX shared memory object to which the sub-processes will attach. I am confused about the things he said about parent process.why I'm not getting the right primes?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/mman.h>
[Code]....
View 10 Replies
View Related
Mar 16, 2013
I just got assigned a project in my C programming class. The objective is to find the min and max number out of a .txt file full of numbers on separate lines called "data.txt". I am pretty much stuck at this point. I don't know how to actually scan the file and print the min and max. Also, the list of numbers in the data.txt file contains hundred on hundreds of numbers. So I couldn't specify the exact amount of numbers listed in the file. I must also find the count number, sum, and the average of the given data, So far I have:
Code:
#include<stdio.h>
int main()
{
int counter=0;
int maximum=0, minimum=1;
int num_data_points, avg;
double max, min;
FILE *sensor;
sensor = fopen("data.txt", "r");
[Code]...
View 6 Replies
View Related
Aug 3, 2012
This is the first time I'm trying to program in C# and I'm having some trouble.I can't find a way to compile whatever I do.I don't think it's a problem of what I wrote but I might not have what is necessary.I tried: C:>csc fisrt.cs csc was not a valid command.
View 1 Replies
View Related
Oct 20, 2013
I am working on a homework lab in which we have to find all the subsets equal to a given sum from an array of numbers.For example, an array of 7 numbers (1, 3, 4, 6, 7, 10, 25) with a sum of 25 would be (1, 3, 4, 7) and (25)...We are supposed to use dynamic programming to solve this.Now using the code below that we went over in class (Sedgewick's subsetSum), I understand how to this finds the first subset that adds up to the sum given. What's stumping me is how to find multiple subsets.
Code:
main(){
// Get input sequence
int n; // Size of input set
int m; // Target value
int *S; // Input set
int *C; // Cost table
int i,j,potentialSum,leftover;
}
[code]....
In class the teacher said it would be mainly just modifying the code we went over in class.
View 1 Replies
View Related
Jun 9, 2014
when I try to run the program (new to VC++, I click the green arrow next to "Debug" in the toolbar, right) and I get a message box - code builds without errors - but the debugger says: "Unable to start program 'c:users/sal/documents/visual studio 2010/Projects/SFML App/Debug/SFML App.exe Cannot find file specified"...well, I go to the directory it says, and nothing is even in the Debug file.
View 10 Replies
View Related
Dec 2, 2013
how to get this program to find the palindrome? Here is my program:
#include <iostream>
#include <string>
using namespace std;
using std::string;
[code].....
View 2 Replies
View Related
Nov 29, 2014
Would you use regex? (not sure how though)
Or, would you go through the hard way, and iterate through every word, until you discarded (n-1) words and reached the nth word?
The second wouldn't be so short and clear to one who reads the code, therefore i was wondering if there's a neater way.
View 1 Replies
View Related
Nov 4, 2013
How to find the sum of even factors ????
View 1 Replies
View Related
Jan 29, 2015
I need to be able to find every possible permutation using all possible values of a char. But I have to make it be able to form permutations from a length of 1 to variable N. For example, if N=3, I need it to be able to come up with
0x00
0x01
.......
0x00 0x00
0x01 0x01
.......
0xff 0xff 0xfe
0xff 0xff 0xff
How could I do this. (I would like to avoid recursion, since N might be as large as 50 or 60 and using recursion would most likely cause a stack overflow)
View 3 Replies
View Related
Jul 26, 2014
How can I find each and every pixel in a circle so that I can do some operations on it.
View 6 Replies
View Related
Aug 25, 2013
I know how to find find ASCII value of given character, but I am not getting how to find ASCII value of given string. For example I want to find ASCII value of string "HELLO",so how to do that.
View 13 Replies
View Related
Oct 28, 2013
Just wondering about how to write extremely simple version of 'find' in C: It just lists the path names of the files in the specified directories and all subdirectories.For example,
Code:
$find_version .
./foo
./bar
./baz
./baz/other
[Code]....
View 6 Replies
View Related
Mar 12, 2014
I got a code written in Java. But, I gave up writing code in Java. The program written is supposed to find the maximum subsequence sum. It's originally like this.
Code:
private static int maxSumRec (int [] a, int left, int right)
{
if(left == right)
if(a[left > 0])
return arr[left];
[Code] .....
I turned it into C, add some elements (to generate random numbers and change some variables' names), and becomes like this
Code:
int maxSumRec (val, left, right)
{
int x;
long int arr[val];
srand ( time(NULL) );
for(x=0; x<val; x++)
[Code] .....
It fails to compile. What have I done wrong? And I keep wondering why in the original code there is left and right variables and their values are never assigned. My c compiler (I use codeblocks) keeps telling me that. Idk why. My friend who keeps it in Java says it is fine but he cannot explain how his program works. What *is* left and right actually?
View 8 Replies
View Related
Jun 16, 2013
The method doesn't work properly, the point of the code is to tell the minimum value in the given matrix "m", it's supposed to take the first value of the matrix store it in min_ and then compare it to every value of the matrix, if the value stored in min_ is bigger than the current value in the loop then it's stored as the new min_ and at the end it's supposed to print that minimum...
Code:
#include <stdio.h>
#include <stdlib.h>
#define SIZE 3
void minimum (int mat[SIZE][SIZE]){
int r,c;
int min_;
printf("
[Code] ......
View 5 Replies
View Related
Oct 29, 2014
Any way to determine the highest value of an array I created with random numbers. I am confused because the array needs to be initialized in the main, but populated in a function. I was able to populate it using a pointer variable and my results came out good for the initial array values and elements.
In order to figure out the max, I think I would need the results of the populated array. How do I do this when the populated array is stored in a pointer variable? Would I need to create a pointer to the first pointer I created? I tried creating another pointer to the initial array and printing that, but my results were not good.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
[Code].....
View 10 Replies
View Related
Mar 6, 2015
I am entering numbers to float ... I want program to find out, which first number is not from specific interval. How to do it ? Example: Enter input : 5 10 20 30 50 46 . 30 is invalid. Here is the code :
Code:
while(scanf("%f",&input)!=EOF || input==0) {
sum=input+sum;
if (getchar() == '
[Code]....
View 3 Replies
View Related
Jun 11, 2013
I want to find the remainder of the division between a and b, but without using the reminder operator a%b.I thought to subtract b from a as long as a>b, that will give the remainder, but I don't know how to write it in code.
View 11 Replies
View Related
Jan 13, 2013
I have the following file (I did everything in the .h file as I think that is a much cleaner way to do this, I realize my compile times will increase.
#ifndef PANEL_H
#define PANEL_H
#include <string>
#include "Container.h"
using namespace std;
}
[code]....
View 7 Replies
View Related
Aug 10, 2013
For example let say there is vector [1,2,3,4,5,6,7,8,9] and let say there is int n
if i say n=3
I want to find all possible 3 combination
[1,2,3][1,2,4].....such and such
if i say n=4
[1,2,3,4][1,2,3,5]......
I want to know how you write the code depend on the input n. Is it call dynamic programming?
View 4 Replies
View Related
Apr 4, 2013
I just purchased Visual C++ 2010 Ultimate, to start my coding experience. Whenever I try to debug, it gives me this error:
The system cannot find the file specified
It can't find the .exe file, I even Googled it, and tried a few things, without any luck.
View 2 Replies
View Related
Aug 3, 2014
I'm currently on an exercise that specifies that I find any repeated words, "the the" for example, in a string, print the word that is repeated and how many times said word is repeated using a while loop that reads one word at a time and break statements when a repeated word is found. Having a bit of a falling out with iterators tonight and I'm not doing to well.
View 7 Replies
View Related
Oct 7, 2013
Lets assume, I use array of 100 the i input 50 element and now i want to find which one is first in array... without using pointer ...
View 2 Replies
View Related
Jul 4, 2013
I am trying to find the median of an array in c++.
This is the array that I would like to find the median for.
scores[14] = {62,70,98,71,81,99,74,80,73,88,73,72,95,71};
View 5 Replies
View Related