C# :: How To Rearrange Lists In A Special Manner

May 15, 2014

how to rearrange lists in an special manner.

I have heard about the hashset but I do not fully understand how that thing works or if it is the best option for this issue.

Basically I have 3 lists: LIST1, LIST2 and LIST3.

LIST1 is a set of xyz points and LIST2 shows how the points are connected (clockwise, counter clockwise, coolinear).

For example the fact that in the first line of LIST2 appears 0, 1, 2,-1 means that the points in LIST1 are connected as follows:

(0 0 128.588459085565)->(25 0 134.979628462965)->(0 0 134.979628462965)

Same for line2 of LIST2: 1, 4, 2,-1

(25 0 134.979628462965)->(25 0 140.100717207301)->(0 0 134.979628462965)

etc...

The value -1 at the end of each line does not mean anything but I need to keep it.

Finally LIST3 tells me if the points are connected counterclockwise (-1), clockwise (1), or coolinear (0).

The thing is that I want to get things as follows:

If the values of list 3=1 then I need to extract all the points in the list 1 that correspond to the value 1 in order. However the values in LIST2 cannot keep being 1, 4, 2,-1 they need to be reorganised starting by zero. Expected result in LIST2= 0,3,1,-1.

We need to do this for each value in list3 (1,-1 and 0).

The idea is to get 3 groups of values:

- Group 1 including all the values that are clockwise (list3) with the points in order in list1 and showing connections starting from zero on in list2.

- Group 2 including all the values that are counterclockwise (list3) with the points in order in list1 and showing connections starting from zero on in list2.

- Group 3 including all the values that are coolinear (list3) with the points in order in list1 and showing connections starting from zero on in list2.

The idea is to be able to print 3 files in the following way:

FILE1:

Points which are clockwise in LIST 1
...

Connections of those points in LIST 2
...

FILE2:

Points which are counterclockwise in LIST 1

[code]....

View 5 Replies


ADVERTISEMENT

C++ :: Initialize A Class In A Manner Similar To C Arrays

Jan 6, 2015

In my case, it involves making a wrapper class of sorts for the std::set. I'm wanting to go all-out on it and make some "fashionable" constructors for it, one of which being similar to C-style array initializations.

// C-array initialization.
int array[5] = { 1, 2, 3, 4, 5 };

// Some example usage of what I'm wanting.
Set<long> num_set = { 10, 20, 30, 40, 50 };
Set<std::string> str_set = { "Hello", "I", "am", "a", "set." };

I almost never overload operators when I work--if it can be done with a function, it's done with a function--but I realize that doesn't make the best user-experience when other people come across your code, so that's what I'm trying to improve.

It looks like I'm going to be needing to overload the = operator, no big deal. But the array segment is confusing, since {} is not an overloadable operator in C++.

View 2 Replies View Related

C Sharp :: GET Values From Table In A Recursive Manner

Nov 14, 2013

I am trying to work with C# and i am stuck here. My problem is i want to retrieve the count of all the users in a specific side. Let me Explain. Here is my table snapshot with sample data.

Now what i want exactly is that i get the count of users in a specific side as i give a user id as a parameter.The data is stored in MS Sql Database and i have to implement this on a website so efficiency of code is also a issue.

Suppose i give 1001 as input
The output should be : Left:1 , Right: 8

if 1002 is input
The output should be : Left:5, Right:0

if 1003 is input
The output should be : Left:3, Right:0

if 1004 is input
The output should be : Left:0, Right:0

if 1005 is input
The output should be : Left:1, Right:1

and so on. how to implement this thing. I also want to get a code which would return an array of all child users of a particular ID in a hierarchical manner so that i could process that data with RadOrgChart Control.

Attached Images scr.png (14.9 KB, 36 views)

View 1 Replies View Related

C :: How To Rearrange Structure Element On The Basis Of Positions Given In Other Array

Apr 8, 2013

I want to rearrange the positions of structure elements on the bases of perm_array.

Code:
typedef struct gg{
element d;
int group;
} gg;
gg col_data[16];

[Code] ....

How can i rearrange structure element like {ptr+2,ptr+3,ptr+1,ptr+0} ?

View 2 Replies View Related

Visual C++ :: Rearrange Controls In Controlbar Based On New Size?

Feb 3, 2014

I have to rearrange my controls in a controlbar based on the new size resulting from dock/undocking of the bars or resizing of the mainframe.

Is there a message I can use? How to determine the new height when docked?

I tried to use its OnSize-function. The problem with it is to get the new height. When the function is called, the height I get from GetWindowRect is the old height.

Is there a better function than OnSize() ?

View 3 Replies View Related

C/C++ :: Read In Numeric Representation Of Date And Prints It Out In Formatted Manner

Oct 13, 2014

Write a program that reads in the numeric representation of a date and prints it out in a formatted manner as the box below.

1. If the user entered an invalid number for the month it should display "Invalid Month"
2. If the user entered an invalid number for the date it should display "Invalid Date"
3. Check to see if the day is outside the range for that particular month

An example of the input and the output:
Enter the date: 1 24 2013
The date you entered is: 1242013

Im not sure on how to go about this problem, but this is what I have.

#include <stdio.h>
int main(void) {
int a, b, c;
int status;
printf("Enter the Date");
status = scanf("%d,%d,%d",&a, &b, &c);
printf(" The Date is : %d",status);
return 0;
}

Am I going about this right? Is there an easier or better way to go about it? All that happens is that the program reads the first number and spits that back out.

View 5 Replies View Related

C++ :: Audio Files - Chop A Song Into Pieces / Rearrange Then Save

Mar 9, 2012

To what extents can C++ edit, maintain, or create audio files?

Ex. I would like to chop a song up into pieces and re-arrange them, and then save the song.

Ex. Play the first 30 seconds of a song

View 3 Replies View Related

C/C++ :: Put Special Chars In A Message

Apr 10, 2014

I'm trying to put in my messages, in my program, some special chars but when i try something like the following code, i get the output below.

#include <stdio.h>
int main( ) {
printf("Trying this char: %c", 160);
printf("Trying this char: %c", 163);
return 0;
}

Output:
Trying this char: �
Trying this char: �

How can i put those special chars? I would like to use: é, ú, ç, à, Ú, À, ...

View 14 Replies View Related

C++ :: How To Output Special Symbols

Jan 30, 2012

For example, how to output "Delta" (like a triangle) in C++?

View 13 Replies View Related

C++ :: How To Make Special Purpose Libraries

Apr 30, 2014

There are many libraries in C++, but how are they made?

For example: SDL, SFML, Open CV, STK

There are no special functions in C++ from which we can create such libraries, If I wanted to create a library that processes sound signals, how would I do that? How can I access the mic, speakers and process the signals.

Open CV processes videos but which functions does it use?

View 3 Replies View Related

C++ :: Array In Class - Set With A Special Ordering

May 24, 2013

I have an array in a class with some numbers in a specific order. Now I want to create a set with references to that array ordered after the arrays content. I thought a solution could be something like

class Holder {
int o[10]= {1,5,7,2,3,8,4,9,6,0};
public:
set<int,my_order> m_s;
Holder() {
for(int i=0; i<10;i++) {
m_s.insert(i);

[Code] ....

How to create the my_order.

View 9 Replies View Related

C++ :: How To Determine A Special Character In A String

Feb 6, 2015

I have to make an email validation program and i am halfway done. I only have one more problem, consider the ff. example:

Enter email:
myemail.@something.com //this is the input
Invalid //this should be the output

How can i determine if there is a special character near the '@' sign? and vice versa?

View 4 Replies View Related

C++ :: Verifying If The Number Is Special And Not Scary

Feb 22, 2012

Code:

Exercise. 1.5 A number is special if it is divisible (no remainder) by 15. A number is big if it is greater than 999. A number is weird if it is divisible by 5 and 6 but not 18. A number is scary if it is big or weird.

Write a program to check which of the following, 450, 540, 600, and 675 are special but not scary.

Declare four variables called special, big, weird, and scary and make suitable assignments to these variables as a number is tested.

I want to do it with a function, but it just output that everything is Special and Scary, and that everything values 4199536.

Code:
#include <stdio.h>
#include <stdlib.h>
/* Function */
int test(int);
int test(int a) {
int sc, sp;

[Code] .....

View 5 Replies View Related

C++ :: Building Special Order Of Elements For Given Sequence

Jun 1, 2013

Let assume that there is an array of integer numbers in the range from 1 to N that are located in the ascending order. For example

#include <iostream>
#include <numeric>
#include <iterator>
int main() {
const size_t N = 20;

[Code] .....

How can it be converted using some one standard algorithm such a way that the resulted sequence would look like

1 3 5 7 9 11 13 15 17 19 20 18 16 14 12 10 8 6 4 2

View 19 Replies View Related

Visual C++ :: Grab Special Lines From A File

Nov 28, 2012

I have a file that contain different content, some lines inside that file looks like that :

Time : xx:xx:xx
Time : xx:xx:xx

So, I want to grab lines that start with "Time : " and put them inside a list<string> for later use. I am using windows so I don't know if the newline character is '
' or '
' also I don't want my grabed line contain any special character.

I have this code, but didn't work well because some special characters remain inside the string.

Code:

string buf;
list<string> ls;
ifstream read("test.txt", ios_base::binary);
while(!read.eof())
{
getline(read,buf,'

[Code]...

View 1 Replies View Related

Visual C++ :: PrintDlg With Special Page Range

Mar 24, 2014

In my app the user can select the pages to print by typing in a start and an end page. I think this is the standard dialog.

How can I give the user the possibility to select e.g. page "1,2,6-9" like in Word?

View 4 Replies View Related

C :: Modifying Code To Handle Uppercase And Special Symbols

May 23, 2013

My code is currently reads in a string of lower case letters, identifying the occurrence of each letter.

Code:
#include <stdio.h>
#include <string.h>
int main()
{

[Code]....

My issue is that I want my code to read uppercase and special symbols. showing the occurrence of both.

Code:
else if(str[x] >= 'a' && str[x] <= 'z');
else if(str[x] >= '0' && str[x] <= '9');

However I struggle to implement it

View 3 Replies View Related

C++ :: Program To Extract Special Code From A List Of Numbers

Nov 1, 2013

I am a beginner and I ALWAYS have the toughest time doing I/O files. It's extremely frustrating. It "seems" it should be so simple. The program should find a code from a list of numbers. These numbers are from 0 - 9, and after each number is a space in the file. Your job is to extract a special code containing only 10 of those numbers. For the number to be part of the code, it should be divisible by 2. After extracting 10 numbers divisible by 2 for the code, write those 10 numbers to the file to form the expected code.

Input file is ("question.txt")
Output should be ("code.txt")

Should this contain a "for loop" or If/else ?

Here's what I did . .

/
// int numbers, total, counter;
ifstream inFile;
inFile.open ("question.txt");
outFile.open ("code.txt");
if (!inFile)

[Code] ....

View 2 Replies View Related

C++ :: Program That Can Detect Special Type Of Memory Leaks

Sep 18, 2014

I'm searching a program that can detect a special type of memory leaks, like these:

int a = 12;
char c[10];
char cc = c[a];

View 8 Replies View Related

C Sharp :: How To Pass Special Character To Process Argument

Mar 5, 2013

How can I pass ":" or " " as an argument to a process?

I start a process which takes an IP and port number (ex 222.240.224.131:80) as argument. Another character that I want to pass is white space character. Both of these characters cuts the argument string and sends only the part that leads them.

View 1 Replies View Related

C++ ::  permutation For Two Different Lists

Nov 7, 2013

I got a permutation question, I got two different std::list:

list<string> slist;
slist.push_back("str111");
slist.push_back("str222");
slist.push_back("str333");

list<int> ilist;
ilist.push_back(100);
ilist.push_back(200);

I need the permutation for both two lists, the result should be like this:

#include <iostream>
#include <string>
#include <list>
#include <algorithm>
using namespace std;
template <typename value_t>
void dump_list(const list<value_t>& lst) {

[Code] ....

See, there are two do while loop, if I need a permutation with more than two lists, there'll be more and more do-while loops, that's make code looks ugly, I wonder if stl has some tricky way that can do this with just one next_permutation.

View 5 Replies View Related

C++ :: Linked Lists - Trying To Revive

Dec 27, 2013

I'm trying to set up a simple implementation of a double linked list. I can't make it fly.

Code:
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

[Code] ...

I seem to create a root vertex, but I can't establish if I connect sub nodes to my list.

View 13 Replies View Related

C :: Merging Two Linked Lists?

Mar 6, 2015

I am merging two linked list but the output of the program is not printing insert

Code:
typedef struct Merge
{
int info;

[Code].....

View 1 Replies View Related

C :: Dynamic Linked Lists

Oct 14, 2013

In our homework assignment it states to, "write a set of dynamic linked lists" and so on. Now, the problem I'm confusing myself is at the storage inside of each node. To my understanding, each node contains the prev and next nodes, but also a pointer to the data, in this case being a string. He has asked us to manage these strings as rows of chars such as

char[0] = c // first node being addressed here
char[1] = a
char[2] = t
char[3] =
char[4] = d // second node starting here
char[5] = o
char[6] = g
char[7] =

I have written my code where each node is holding a string, not separated as shown above... my question is to how you can build your doubly linked list where each node is being address a set of chars.

View 1 Replies View Related

C :: Structured Lists From Text

Apr 5, 2013

New to this C stuff, and was going through Kochan's book Programming in C and got to chapter 9 structured lists.There's this problem that requires you to set a Variable N that calculates days.

N = 1461 x f(year, month) / 4 + 153 x g(month) / 5 + day
where
f(year, month) = year-1 (if month <=2)
=year (otherwise)

g(month) = month+13 (if month <=2)
= month+1 (otherwise) Code:
struct date {
}

[code]....

I was having issues getting the right values for N so I tried to see what T1.year gives me when I type in firstDay.month=02, firstDay.day=08 and firstDay.year=1999, and I got 8. According to book I should be getting 1998.

View 2 Replies View Related

C++ :: Nodes In Linked Lists?

Feb 26, 2015

I created a bunch of nodes and I made each one before one another. Im having trouble adding another node to the last one.

#include <iostream>
using namespace std;
struct nodeType{
int info;
nodeType *link;
};
void printList(nodeType *head) {
nodeType *current = head;

[code]....

The node with the value of 400 is the node that has to be last.. How would that work?

View 3 Replies View Related







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