Visual C++ :: Algorithm Recursive Version Implementation?

May 19, 2013

I have a problem to implement a recursive version of an algorithm that I made, I get different values. Here is the code so Iterative (OK) and Recursive code form that is not OK.

The data sets do not give equal:

The algorithm is given two source and target positions on a board, find the number of paths between them...

Input Example: 5
2 3
4 4

Output Example: 5

Iterative Algorithm ( OK )

Code:
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
using namespace std;
int n , dp [1000][1000], x, y, xx, yy;

[Code] ....

View 2 Replies


ADVERTISEMENT

C++ :: Do A Recursive Implementation Of A Heap

Apr 19, 2013

So I'm going through and trying to do a recursive implementation of a Heap. I keep getting access violations for some reason on my sifts (_siftUp) - even though I'm trying to insert into sub[0] (currSize = 0 in the constructor). I don't think either of my sifts are implemented correctly, are they?

Here's my Heap:

Code:
#ifndef HEAP_H
#define HEAP_H
//**************************************************************************
template<typename TYPE>

[Code].....

View 5 Replies View Related

C++ :: Pathfinding Algorithm Implementation

May 11, 2013

I am currently trying to implement a pathfinding algorithm using c++ and opengl. My code so far is shown below:

#define OPEN 1
#define CLOSED 2
#define UNVISITED 3
#define BLOCKED 4
#define HIGHLIGHT 5
#define ONROUTE 6
#define GOAL 7

#define GSIZE 20 // size of tile grid
#define ISTART 15 // index position of starting tile in grid

[Code] ....

View 2 Replies View Related

C++ :: Implementation Running Length Smoothing Algorithm

Feb 7, 2014

I use c++ and opencv. The type of image is Mat structure.

In matlab, I did this :

for i=1:m
for j=1:n
if(image(i,j)==1)
if(one_flag==1)

[Code]....

Another thing is in Matlab the index start from 1 while C++ start from 0.

View 1 Replies View Related

C++ :: Algorithm Has Asymptotic Complexity Recursive?

May 22, 2013

would like to know that my algorithm has asymptotic complexity recursive?

int solve(pair<int,int> actual)
{
if(actual.first == PuntoInicio.first && actual.second == PuntoInicio.second)
return 1;

[Code]....

View 1 Replies View Related

C++ :: Memory Allocation Recursive Algorithm

Dec 27, 2014

I've been working on a matrix class and I ran into a problem in writing my matrix class. I keep getting 0 as a determinant and with some debugging, I found that I was losing allocated data or something similar. This algorithm I'm pretty sure works because I used this same algorithm in a function I made in python. [URL] .... That's where I found the algorithm.

/*template <class T>
double Matrix<T>::det(T* array, size_t dim, bool recursion)*/
double det(T* array = NULL, size_t dim = 0, bool recursion = false) {
if (recursion == false) {
if (m != n) {
return 0;

[Code] .....

View 2 Replies View Related

C/C++ :: Seg Fault In Recursive Sorting Algorithm

Apr 23, 2015

So I am working on a dual pivot quicksort, I can correctly sort the array the first time around however in the main it is called again on the sorted array and in the function I get a seg fault at line 17 in sort.cpp, for the life of me I cant figure it out as the values are the same when I pass it in the first time. Here is the code:

main1.cpp

#include <iostream>
#include "movement.h"
#include "sort.h"
using namespace std;
int main() {
const int size = 10;
T array[size] = {6, 5, 1, 8, 4, 7, 2, 9, 6, 3};

[Code] ....

View 4 Replies View Related

C++ :: Simple Recursive Maze Algorithm And Counting Steps

Jun 1, 2013

My maze algorithm must be able to count total steps. He is not allowed to "jump" from a deadend back to the cross-way he originally came from.

Code:
int R2D2Turbo::findIt(Labyrinth* incLab, int x, int y){
if ((x == incLab->getExit().x) && (y == incLab->getExit().y))
{
return 1;

[Code] .....

Due to the nature of recursive algoirthms, he jumps instead of moving the way back from the deadend one by one... The only solutions I could think of are way overloaded...

View 3 Replies View Related

C++ :: Implement Quick Sort Algorithm Using Recursive Function

Feb 13, 2013

I have written this code to arrange user input array in an order.

//Recursive Quick Sort
#include<stdio.h>
#define ARRAY_SIZE 10
void quick_sort(int array[], int len)
}

[code].....

View 6 Replies View Related

Visual C++ :: How To Extract Machine / Hardware ID And OS Version

Nov 19, 2014

Is there a way I can extract Machine / Hardware ID and OS Version using VC++?

View 3 Replies View Related

Visual C++ :: How To Set Property For Using Static Lib File (2003 Version)

Jan 15, 2013

Later i used trial version of vc2010 and created a static library using the below link. Its worked. [URL] .....

But now I'm using VC2003.Details as follows,

Microsoft Development enviroinment 2003 Version 7.1.3088
CopyRight @ 1987-2002 Microsoft Corporation. All Rights Reserved.

Microsoft .Net Framework 1.1 Version 1.1.4322
CopyRight @ 1998-2002 Microsoft Corporation. All Rights Reserved.

I used the same procedure & created the Static lib. But couldn't use this lib file in my main project.B'cos the project's property window doesn't have the :

Common Properties -> Framework & References

Couldn't find. Here with i attached missed property in VC2003. How can i set this property? Is any other way to use static lib in main project (application)?

View 4 Replies View Related

Visual C++ :: Launching Current Version Of IE To View HTML File From Program

Nov 29, 2012

I tried to do this with _spawnl(), but first of all I'm not sure how to properly ask for the path to iexplore.exe, as I'm sure it will change every time MS gets a whim to move it. I know there's a GetWindowsDirectory() call, but that's not where IE resides (its in "C:Program FilesInternet Exploreriexplore.exe" in XP, Lord know where on win 7 or 8).

Also, even temporarily hard coding the path to make it launch with spawnl(), I can't seem to get my html document to display. I know the path to that is right (since I put it there ).

char * pFile = "someFile.htm";
char * pCmd = "C:Program FilesInternet Exploreriexplore.exe";

int res = _spawnl(_P_NOWAIT, pCmd,pCmd, pFile, NULL); // also tried without specifying pCmd 2x
if (res == -1) MessageBox("Can't Open File.");

So my second question would be, how to you PROPERLY pass the file to view as an argument.

View 7 Replies View Related

Visual C++ :: Class Specification / Implementation File

Oct 2, 2013

I keep getting this error

In file included from /usr/lib/gcc/i686-redhat-linux/4.5.1/../../../../include/c++/4.5.1/bits/ios_base.h:43:0,
from /usr/lib/gcc/i686-redhat-linux/4.5.1/../../../../include/c++/4.5.1/ios:43,
from /usr/lib/gcc/i686-redhat-linux/4.5.1/../../../../include/c++/4.5.1/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.5.1/../../../../include/c++/4.5.1/iostream:40,
from player1.cpp:3:
/usr/lib/gcc/i686-redhat-linux/4.5.1/../../../../include/c++/4.5.1/bits/locale_classes.h:45:1: error: expected unqualified-id before "namespace"

What does it mean? I am working on classes and this error comes when I run the implentation of my class file.

//Implimentation of class player1 (player.cpp)
#include "player1.h"
#include <iostream>
//using namespace std;
void player1 :: Set_Name()

[Code] ...

View 2 Replies View Related

Visual C++ :: Interaction Between Algorithm And Winsock

Jul 24, 2013

Code:
#include <algorithm>
#include <winsock.h>
void some_func() {
int result = std::min (0, 16384);
}

Okay, but the above code consistently gives me error C2589: '(' : illegal token on right side of '::'. I'm building with VC8. If I don't #include <winsock.h> the code compiles correctly but it doesn't matter if I #include <winsock.h> before or after including <algorithm>

I guess it might be due to one of my #defines but I've tried the code in a very minimal program and I still get the error.

View 7 Replies View Related

Visual C++ :: Put A Message String Through Algorithm / Cryptography?

May 31, 2013

I'm looking for a resource (possibly CPP) for which I could do the following on a windows and linux machine:

1) type a string message into a GUI control (or some other input that can be accessed by the resource).

2) run a resource script that puts the message through a hash function (or a custom hash function) and outputs the hash string.

3) have a reverse function available in order to decrypt the message in an input fashion just like step #1.

what open-source resource might be the best for this? Right now I am imagining typing a message into a text file, saving the file to a hard drive location, running a script on it replacing the old file with a new file that just has a hash string in it, then using that hash string for the encoded message.

View 4 Replies View Related

Visual C++ :: Assignment Is Recursive Call And Placing Strings In Link List Notes?

Oct 30, 2013

You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null.

The permute class uses a Note class as link list note to link all letters arrangement. The permute class has Note pointers, firstNote and lastNote, to point to the beginning and ending Notes of the link list as private data members. There are three other private data members (total, firstString and secondString) to store the total possible number of arrangements and strings pass into the class.

Write a driver to test the permute class to pass in any two strings of any sizes.

Other than mention in the following, you can add more classes, functions, and private data members to this program.

Note class:The Note class needs to have two private data members and a constructor. The two private data members are data and p pointer. The data’s data type is string and p pointer is Note. The Note class constructor has two parameters, one is string and the other is Note pointer.

Permute class:The Permute class has five private data members (*firstNote, *lastNote, total, firstString and secondString). The firstNote and lastNote pointers are point to Note. The total has integer data type. The firstString and secondString have string data type.

There should have at least three public member functions, Permute, permutation and print. The Permute function is the constructor which takes strings to initialize the private data members. The permutation function does the recursive call to arrange the strings and setup the link list. The print function will print out the private data member information.

Driver file:The driver file should declare a Permute eight elements pointer array. Instantiate eight Permute object with the following eight set of data and assign the object to the pointer array. Use a repetition to call the object’s print function to print out the private data member information. If the total of the permute private data member is less than 100 then print out the permutated letters four in a row, otherwise print out 9 in a row.

first = "", second="",

first = "", second ="CATMAN",

first = "C", second ="ATMAN",

first = "CA", second ="TMAN",

first = "CAT", second ="MAN",

first = "CATM", second ="AN",

first = "CATMA", second ="N",

first 1 = "CATMAN", second ="";

View 3 Replies View Related

Visual C++ :: Runtime Error In Merge Sort Algorithm

May 3, 2013

# include <iostream>
# include <vector>
# include <cstdio>
# include <algorithm>
# define inf 100000

using namespace std;
int cnt;
vector<int> merge( vector<int>& left, vector<int>& right) {

[Code] ....

View 6 Replies View Related

Visual C++ :: Arbitrary Sort Algorithm For Input (Bunch Of Rows)

Apr 5, 2013

C++ sort algorithm or library that can take input of a bunch of rows of data and then sort rows by an arbitrary defined order of one of the columns ... i.e., sort rows by value of the first column in this order (boba bobc bobe bobx) etc?

View 1 Replies View Related

C :: Simple Version Of Find

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

C :: Determine Compiler Version And Which Standard It Uses?

Jul 18, 2013

Is there any code I can use to determine my compiler version and which Standard It uses? I know the following code determine that my compiler followed ANSI But how about a version of that? ****My OS is now Ubuntu

Code:
#include <stdio.h>
int main(void){
printf("File :%s
", __FILE__ );
printf("ANSI :%d
", __STDC__ ); //return 1 if it follow ANSI but version?
return 0;
}

View 3 Replies View Related

C :: Version Number Stored In EXE File

Feb 24, 2015

I am/we developing in C and we have a number of different programs. We also have problem to keep track of different versions of a specific exe file.

Is there any way to add version number when build a file so the version is added in the properties.

I doing this in a MFC c++ project in a .rc file. Is there a way (or a similar way) of doing this in C? Here its stored in the details section with product version 6.0.8:

View 6 Replies View Related

C++ :: Standard Way To Add Version Number To Code?

Apr 15, 2014

Just wondering if there was a standard way people add a version number to their c++ code? I can just define a variable or #define and write the version number to that, but wanted to know if there is a standard method people use?

View 1 Replies View Related

C++ :: Change The Version Info Of The File?

Jan 18, 2013

im trying to make a tool that can change the version of the file (.exe)

UpdateResource(hResource, RT_VERSION, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPVOID) lpBytes, dwSize);

i know how to update the rcdata of the resource

my problem is i dont know what to insert to it using (LPVOID) lpBytes is it a .txt ? .rc ? is it a binary ? etc.

View 1 Replies View Related

C++ :: Version Numbers For Programs And Projects

Sep 16, 2013

When you are creating a project or program, how do you number your versions?

Like when you release it, it becomes v1.0, am i right?

then every release or build after that might become v1.1 or v1.0001 or v1.0.1.2

Is there a certain global system for how you Number your versions or is it just up to the developer?

View 1 Replies View Related

C++ :: Compiling Static Version Of Boost Libraries?

Mar 6, 2013

I have been trying to compile a static version of the boost libraries, however when I try to launch the program it says fatal error LNK1104: cannot open file 'libboost_serialization-vc100-mt-s-1_53.lib'

I have checked in the boost/stage/lib folder and that file is not there. I compiled boost with b2 link=static yet the file still isn't there.

View 3 Replies View Related

C/C++ :: How To Print Colored Output In Borland Version 4.5

Feb 26, 2014

I am using borland turbo c++ version 4.5 and for printing a coloured output i used textcolor() but it is showing error that call the undefined function 'textcolor' in main, so what can i do now to print a coloured output???

View 1 Replies View Related







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