C++ :: How To Program A Hash Map System Where Each Key Have Multiple Values Under Indexes

Nov 13, 2013

How difficult would it be to program a hash-map system where each "key" can have multiple values under indexes?

For example: "Word" -> 45(index 0) , 67(index 1) , 12(index 2). What could I start with to program this or where could I find a pre-made system that does this?

View 14 Replies


ADVERTISEMENT

C++ :: Tree Arrays Of Same Even Lengths And Adds Values At Odd Indexes

Oct 22, 2013

I am trying a program with that takes tree arrays of same even lengths and adds the values at odd indexes and save at even index of 3rd array and voice versa........

what will be the logic i have tried it a lot of time not worked................

View 3 Replies View Related

C++ :: Hash Table Program - Sorting Pointer Table After All Of Values Entered

Nov 19, 2013

I am having an issue with my sort function. This is one part of the Hash table program. The main issue is that I am trying to sort the pointer table after all of the values have been entered. The ptr_sort function is not a class function and so I am therefore unable to use the class variables psize and pTable. Is there another way I should be trying this? it is a Vector should I use the sort() function from the vector class in STL?

#include "/home/onyuksel/courses/340/progs/13f/p9/util9.h"
#include "/home/onyuksel/courses/340/progs/13f/p9/hTable.h"

#ifndef H_TABLE1
#define H_TABLE1
void ptr_sort ( );

[Code] ....

View 1 Replies View Related

C++ :: Banking System - Searching For And Printing Values From TXT File

Mar 21, 2013

So I'm doing a kind of banking system. Atm I've got the user able to create an account and set the balance of it, which is written to a .txt file. However, I would like the user to be able to enter their account no. and the program to cout the account info on the screen. I will be adding more to the program later, but until I work out how to search for values in a .txt file, and print out values on that line I'm a bit stuck.

Code:
Main.cpp -
#include <iostream>
#include "create_account.h"
#include <fstream>
using namespace std;
int menuin;
int main() {
create_account creataccObj;

[Code] .....

Sample .txt file -

// Account_no - Balance //

1001 140500
1002 150600
1003 18600

View 8 Replies View Related

C++ :: Get Matrix Indexes From The Value

Oct 17, 2013

I have a 3x3x3 matrix with values hanging from 1 to 27.

The order is this: Code: m[0][0][0] = 1;
m[0][0][1] = 2;
m[0][0][2] = 3;
m[0][1][0] = 4;
m[0][1][1] = 5;
m[0][1][2] = 6;
.
.
.
m[1][0][0] = 10;
m[1][0][1] = 11;
m[1][0][2] = 12;
.
.
.
m[2][2][0] = 25;
m[2][2][1] = 26;
m[2][2][2] = 27;

Is there an easy way to compute the indexes given the value? For example, I know that the first index can be found by dividing the value by 9.0: Code: const int firstIndex = ceil(value / 9.0) - 1; What about the second and the third indexes? I couldn't find a pattern in the numbers, and I didn't want to iterate through the matrix (the indexes will be calculated many times).

The other option is to create arrays where the values will be indexes and the matrix indexes will be the values. I'm not sure if it is the best way though

View 6 Replies View Related

C++ :: Returning Multiple Values?

Oct 9, 2013

I would like to return multiple values from one function to access in different functions. For example:

int function1(//what goes here?)
{
int a ;
a = 1 + 2 ;
int b ;
b = 3 + 4 ;

return (what goes here if i want to return the value of a and/or b to use in another function?) ;

void function2()
{
//now i want to use the value of a here to use in an equation, how do i do that?
//now i want to use the value of b here to use in an equation, how do i do that?
}

View 4 Replies View Related

C# :: Store Multiple Values?

May 1, 2015

I am working on a text based RPG. As with most RPGs the character has attributes that grant modifiers. Lets take strength for instance. Suppose the character can have a strength score that ranges from 1 to 10. Based on strength the modifiers could be like the following:

Strength = 1 grants +1 to hit and +1 damage
Strength = 2 grants +1 to hit and +2 damage
Strength = 3 grants +2 to hit and +3 damage

I want to set these values at design time and be able to retrieve the modifiers based on the strength value from multiple places in my program.

What is the best method of designing this. I looked around online and saw references to Lists with Tuples and Dictionaries with Tuples but these did not seem to be a very efficient way of handling the scenario above.

View 4 Replies View Related

C++ :: Map To Access Elements Through Multiple Key Values

Sep 27, 2014

I used to use map to access elements. map has a good feature that it sort the element automatically. Now I need a map which can access element through multiple key values. So I choosed boost::multi_index_container. I defined a container as follows.

struct elem {
int a,b;
elem(int aa,int bb):a(aa),b(bb) {}
};

typedef multi_index_container <

[Code] ....

What I am wondering is whether boost::multi_index_container can sort elements automatically. Specifically, are all elements extracted through iterator from begin to end shown below having b values between 2 and 100?

test t;
test::iterator begin = t.lower_bound(make_tuple(1,2));
test::iterator end = t.upper_bound(make_tuple(1,100));

View 3 Replies View Related

C++ :: Erase Multiple Values In A Vector

Mar 17, 2014

I wud like to delete multiple values from a vector using indexes as my values r not fixed they may change so using indexes i want to delete

For example: vector<int> v={1,2,3,4,5};

I want to erase 3,4,0 indexes

So resulting vector is 2,3

View 6 Replies View Related

C/C++ :: How To Pass Multiple Values From One Function To Another

Mar 4, 2015

I need to pass multiple values from one function to another and how to do this. Here is my code so far.

#include <iostream>
#include <string>
#include <cctype>
#include <fstream>
using namespace std;
//Function Prototypes//
int charString(string, string, string);
string reverseString(string, string, string);

[Code]...

I basically need to take line1, line2, and line3 and return them to the reverseString function. Also, I am not allowed to do anything like make my own classes. I have to stick to the basics and no higher level programming techniques since we have not learned them yet.

View 5 Replies View Related

C++ :: Storing Integers At Odd And Even Indexes In Array

Mar 4, 2013

here is my problem given below Input values (say 10) from user in array, if the value is even then place at even index else at odd index. Then how could i solve this problem?

View 2 Replies View Related

Visual C++ :: Getting Indexes Information From SQL Server?

Jan 6, 2014

Trying to get table indexes information in SQL Server 2012 I identified a strange situation for one scenarion.I have a table that contains two indexes referenced to some fields: Field_1 and Field_3 mapped over int, null columns (the number means the existing field order into the table designed few years ago...).

I am trying to get information about these indexes like this:

Code:
nRetCode = ::SQLStatistics(hstmtAux, NULL, 0, NULL, 0, (TCHAR*)(LPCTSTR)strTempTable, SQL_NTS, SQL_INDEX_ALL, SQL_ENSURE);
if (nRetCode == SQL_SUCCESS || nRetCode == SQL_SUCCESS_WITH_INFO)
{
nRetCode = ::SQLBindCol(hstmtAux, 4, SQL_C_SHORT, &swNonUnique, sizeof(SWORD), &cbNonUnique);
nRetCode = ::SQLBindCol(hstmtAux, 5, SQL_CHAR, szIdxQualif, sizeof(CHAR) * 130, &cbIdxQualif);
nRetCode = ::SQLBindCol(hstmtAux, 6, SQL_C_CHAR, szIdxName, sizeof(CHAR) * 130, &cbIdxName);
nRetCode = ::SQLBindCol(hstmtAux, 7, SQL_C_SHORT, &swType, sizeof(SWORD), &cbType);
nRetCode = ::SQLBindCol(hstmtAux, 8, SQL_C_SHORT, &swSeqInIdx, sizeof(SWORD), &cbSeqInIdx);
nRetCode = ::SQLBindCol(hstmtAux, 9, SQL_C_CHAR, szIdxColName, sizeof(CHAR) * 130, &cbIdxColName);

[code]....

Becasuse SQLExtendedFetch() is deprecated I used SQLFetchScroll() but the behavior is the same from my interest point of view.

Usally, I get the right information about indexes but in one situation I encounte a strange behavior. It's about having a clustered index into a scenario.
When Field_1 is Non-Unique, Non-Clustered and Field_3 is Clusted index I get the right information.

But if the index Field_1 is Clustered and the Field_3 is Non-Unique, Non-Clustered I get no information about Field_1 index (eg. szIdxName and szIdxColName are "" and their length is -1 that means SQL_NULL_DATA). So, I have no Index information. Within while loop, with the next iteration I get correct information about the second index Field_3.

I'm not sure whether the problem is with SQLStatistics, the bindings or SQLFetchScroll (they all always return SQL_SUCCESS). It looks like a problem with the driver when the first index is clustered.

View 6 Replies View Related

C++ :: How To Return Multiple Values To The Main Function

Oct 13, 2013

in a function how do you return multiple values to the main function.

View 4 Replies View Related

C++ :: How To Get Code To Read Multiple Input Values

Feb 10, 2013

So I have to write a code for my C++ class, and I am having a problem trying to figure out how to get my code to read multiple int values. This is what my code should look like

Enter two times in military format (e.g., 1730 1520): 1730 1520
[1520<1730]
Enter two times in military format (e.g., 1730 1520): 1520 1730
[1520<1730]
Enter two times in military format (e.g., 1730 1520): 1730 1730
[1730==1730]
Enter two times in military format (e.g., 1730 1520): 1760 1520
1760: [INVALID TIME 1]
Enter two times in military format (e.g., 1730 1520): twelve 2
[INVALID NUMERIC INPUT]

View 1 Replies View Related

C# :: Linq To XML - Populate List With Multiple Values?

Aug 26, 2014

I have an XML document, formatted as such:

<?xml version="1.0" encoding="UTF-8"?>
<Books>
<Bookmark Name="1984" Folder="C:UsersmillerDownloads1984 (George Orwell) - Audio Book" Time="00:43:58.4080000" Chapter="0" />
</Books>

Each Element named Bookmark has 4 attributes, Name, Folder, Time, and Chapter.

I'd like to be able to just put all of them in ONE type of container, without making multiple lists... Is there any way, using Linq to XML, to maybe add all of these values to a Tuple?

View 14 Replies View Related

C++ :: Save The Indexes Of Multi-dimensional Arrays

Apr 8, 2014

I am working on the game of fifteen.Yes this is home work. I was wondering if it is possible to save the indexes of an element in a two dim array. I need to find the position of the space in the two dim array save it, find the position of the tile which is passed in as an int and swap the two if they are adjacent. Here is my code

Edit: I can do this by saving i and j in separate int variables but is there a more elegant way of doing this

int board[MAX][MAX];
void init();
void swap(int* lhs, int* rhs);

[Code].....

View 3 Replies View Related

C++ :: Strings - Read Multiple Values In On A Single Line

Jul 28, 2014

My question is on c++ strings. At the moment my program is reading input in one line at a time after the user presses enter.

I want to read multiple values in on a single line. Example: "apple banana orange end" ... How would I do this?

MAIN Code:
#include "Header.h"
#include "Orange.h"
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

[Code] ......

View 11 Replies View Related

C :: Read From And Store Values Of Each Line In Multiple Variables

May 6, 2013

So I have this text file that I am trying to read from and store the values of each line in multiple variables. Let's say my text file contains

AXSYZ3482 Tom 100 112 and my code below here works fine when the lines in the text file is separated by spaces.

Code:

while (fscanf(fp, "%s %s %d %d
", userID, name, &startLoc, &endLoc) != EOF) {
printf("%s %s %d %d
", userID, name, startLoc, endLoc);
}

But let's say my file was to look like this instead.

AXSYZ3482:Tom:100:112

But if i try this below...

Code:

while (fscanf(fp, "%s:%s:%d:%d
", userID, name, &startLoc, &endLoc) != EOF) {
printf("%s %s %d %d
", userID, name, startLoc, endLoc);
}

It seem to store the entire line in userID including the ":". I want to ignore the ":"'s and store everything in between in respective varibles in the order specified above.

So first string in userID, then ignore the :, then second string in name, and ignore the next :, and so forth.

View 4 Replies View Related

C++ :: Write A Program That Replaces Values In A Vector With Their Absolute Values

Dec 4, 2013

This is my code: [tag]

Code:
#include <iostream>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

[Code] .....

View 4 Replies View Related

C++ :: Loop Through Indexes In Guess Array And Assign M Randomly

Jan 19, 2013

Just run a loop through each of the indexes in the guessarray and assign 'M' to them randomly.

View 2 Replies View Related

C :: Banking System - ATM Program

Mar 27, 2014

I am working on a project that is like a banking system and needs to include making a withdrawal, transaction, deposit, query, and transaction.

Code:
#include <stdio.h>
//#define true
//#define false
//assume there is money in the account. $10,000
void deposit(){

[Code] ....

View 1 Replies View Related

C :: Program For Ordering System

Mar 1, 2013

I just started my task with Ordering system. what should I use if I'm going to ask the user if he wants to exit the system, he will press(zero)0 to exit the program and press Y(uppercase or lowercase) to continue?

View 1 Replies View Related

C++ :: Call A Program By System

Apr 17, 2013

So I know that I can call a program by system("prog.exe"), but what do I add in when I want to pass a parameter?

View 2 Replies View Related

C++ :: Reading From File And Store Values Of Each Line In Multiple Variables

May 6, 2013

So I have this text file that I am trying to read from and store the values of each line in multiple variables.

Let's say my text file contains

AXSYZ3482 Tom 100 112

and my code below here works fine when the lines in the text file is separated by spaces.

while (fscanf(fp, "%s %s %d %d
", userID, name, &startLoc, &endLoc) != EOF) {
printf("%s %s %d %d
", userID, name, startLoc, endLoc);
}

But let's say my file was to look like this instead.

AXSYZ3482:Tom:100:112

But if i try this below...

while (fscanf(fp, "%s:%s:%d:%d
", userID, name, &startLoc, &endLoc) != EOF) {
printf("%s %s %d %d
", userID, name, startLoc, endLoc);
}

It seem to store the entire line in userID including the ":". I want to ignore the ":"'s and store everything in between in respective varibles in the order specified above.

So first string in userID, then ignore the :, then second string in name, and ignore the next :, and so forth. How I can accomplish this?

View 2 Replies View Related

C Sharp :: Displaying Values In Multiple Textboxes Using Single SQL Command

Apr 23, 2012

I've a html table in my web form which contains 30 rows of textboxes. I want to display all the textbox values by using a search command...

View 1 Replies View Related

C :: Program Stalled At System Command?

Dec 22, 2014

I am trying to recreate this bash command in c code:

Code: bash-4.2$ exec 3<<<teststring
bash-4.2$ cat <&3
teststring
bash-4.2$

I've written a small program to do this as shown below:

Code: bash-4.2$ cat test.c
#include <stdio.h>
#include <string.h>
#include <fcntl.h>

[Code].....

View 3 Replies View Related







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