C++ :: Selecting Elements From A Group?
Jul 16, 2013
I have N vectors which look like this:
[1→m] [m+1→2m] [2m+1→3m] [3m+1→4m] [4m+1→5m]..... [{(N-1)m}+1→Nm]
I want to select 1 element from each vector without duplication of any combinations.
Essentially only when all combinations are done with 1st element in first vector ,only then it should move to next element in first vector say i have elements :[123] [456] [789]
my combinations should be like
147
148
149
157
158
159
167
168
169
247….
Also, i need no repetitions and only after all combinations of 1 are done only then the loop has to move to next combination ie 247 combination and so on.
i tried NCK (n choose k) command but it gave me random combinations.how should i go about it with using minimal for loops
View 1 Replies
ADVERTISEMENT
Sep 10, 2013
Supposing you have a 3 or more overlapping arrays (arrays having elements in common), and you wish to select 2 or more of the arrays with the maximum number of elements but less overlap as compared to the rest of the overlapping arrays.
Eg. A[4],B[6],C[5]. A+B contains 10 elements but say the overlapping element is 3, meaning it has 7 unique element.
Also B+C=11 elements , but supposing it has 5 overlaps, it would mean it has only 6 unique elements. A+B+C=15. Supposing the overlaps are 11 then it means the unique elements are 4. Ect. So per the example, the best array options with most unique element would be A+B .
View 4 Replies
View Related
Dec 14, 2014
it's not my primary language, so my code variables are in my language.
Code:
FILE *eng;
eng = fopen("eng.txt", "r");
if(eng == NULL){
[Code]....
fclose(eng); It's a piece of my code. Some explanation: From file, where is full of words under selves. I cut it on word and from word i'm printing:
1) word
2) how many letters in the word
3) word backwards and
4) viz. problem is down
For first: There i have warning: while(feof(eng) == NULL); like (comparison between pointer and integer) i don't get it. For second i have a big problem. I must from every word print the most recurring character.
For example: nondeterministically -> the most are N and I. And if, there is more then one most reccuring char, you choose one of them.
View 5 Replies
View Related
Jul 14, 2014
I have to write a program that selects a random color from an array. I used the srand (time(0)); statement but it still gives me the same color each time. Here is my code.
// Color.cpp
#include <ctime>
#include <iostream>
using namespace std;
#include <string>
#include <cstdlib>
#include "Color.h"
[Code] .....
View 7 Replies
View Related
Jan 21, 2015
I am looking into some design pattern which works for validation.
I thought about using strategy but not sure whether its correct or not
View 3 Replies
View Related
Jan 27, 2014
I'm writing a Hotel magmt app. I'm having difficulty on how to implement a hotel attendant selecting/secure multiple rooms(with nos) for a Customer using combobox or listbox or something. How my interface will look like and techniques.
View 1 Replies
View Related
Jun 5, 2012
I have the following code in the cellmouse event to get information from a selected row.
private void dt_Grid_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
datagrid.Rows[0][0] = dt_Grid.Rows[e.RowIndex].Cells[0].Value.ToString();
datagrid.Rows[0][1] = dt_Grid.Rows[e.RowIndex].Cells[1].Value.ToString();
datagrid.Rows[0][2] = dt_Grid.Rows[e.RowIndex].Cells[2].Value.ToString();
[Code]...
but when i select a collumn, i recive an error because i'm selecting a cell with the mouse and i dont have code for that selection. My question is how can i put an "if" on the beguining of the event so that he can determine if it's a header or not.
View 1 Replies
View Related
Aug 7, 2013
How would I go about selecting a subitem in a listview control with just pure Win32 API? I know it's possible with MFC... but I can't use MFC for this project. Right now, when you click on a subitem , it selects only the first column of the row . I used the following by referring internet. But its not working.
HTML Code:
iSlected=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED|LVNI_SELECTED);
ListView_SetItemState(hList,iSlected,LVIS_FOCUSED|LVIS_SELECTED,0x000F);
View 5 Replies
View Related
Jul 15, 2013
I have N vectors which look like this:
[1→m] [m+1→2m] [2m+1→3m] [3m+1→4m] [4m+1→5m]..... [{(N-1)m}+1→Nm]
I want to select 1 element from each vector without duplication of any combinations. Essentially only when all combinations are done with 1st element in first vector ,only then it should move to next element in first vector.
Say i have elements :[123] [456] [789]
my combinations should be like
147
148
149
157
158
159
167
168
169
247....
Also, I cant have any repetitions and only after all combinations of 1 are done only then the loop has to move to next combination ie 247 combination and so on.
I tried NCK (n choose k) command but it gave me random combinations. How should i go about it with using minimal for loops?
View 2 Replies
View Related
Aug 23, 2012
I was wondering if there is a -> simple <- way to overwrite existing text in a masked texbox...
Example: I have a masked textbox, where you can insert dates. That means that you can enter only numbers for the day, month and year.
If I have to do it programmatically, there is no problem... I already have some ideas how I could do something like that, but I would like to know if VS has any parameter or any option I only have to activate.
View 6 Replies
View Related
Oct 31, 2013
There was an "impovement" since Windows 7 in algorithm for selecting the initial directory, which is described here OPENFILENAME structure. Briefly:
Windows 7:
If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save As dialog box, the path most recently selected by the user is used as the initial directory. Otherwise, if lpstrFile contains a path, that path is the initial directory.
Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory. If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory. Otherwise, the initial directory is the personal files directory of the current user. Otherwise, the initial directory is the Desktop folder.
The problem that this behavior is not what users of my program expect. Another constraint is that I need to use old CFileDialog dialog, not Common File Dialogs. I've tried to use advises described on StackOverflow and on MSDN. This solution by EllisMiller works perfectly:
Specifying a full path (including filename) in lpstrFile. The filename of course shows up in the filename box which is annoying. I ended up using a filename of "." and adding a bit of code to clear the filename combobox once the dialog is open.
BUT I can't figure how to clear the filename combobox. I've tried to add hook procedure, enumerate windows and clear text, but this didn't work for me. So, my question is: how can I clear text in the filename combobox of CFileDialog?
View 12 Replies
View Related
Oct 15, 2013
I'm building a box to take in several arrays of different lengths. one group happens every 10 seconds. one of them happens every 5 seconds. this is from a weather station.
10 sec
subgroupA[14]
subgroupB[24]
subgroupC[17]
subgroupD[12]
subgroupE[34]
5 sec
subgroupC[17]
I plan to retransmit them, substantially unchanged at a lesser rate to save radio power over a serial data link. buried in groupD, I want to change a few chars before retransmit.
I don't want to go to the trouble of doing a structure for each of them since most will be resent unchanged. some entries are chars, some are decimal, some are a mix. I guess it might be convenient to further define groupD, maybe not.
what is the best way to declare the group? I want them to be contiguous since that's how they will end up in the tx buffer. Each subgroup has its own checksum, so I planned it this way to make checksum more convenient.
View 6 Replies
View Related
Dec 13, 2014
I'm a beginner in C programming and I've got a task that can't finish it..I'm supposed to generate and print the subsets of a group that its size I should enter. Pointers are not allowed!!
View 1 Replies
View Related
May 25, 2013
I currently need separating my Prime numbers in group for my assignment. I absolutely do not know how to do this. I am able to find out if the number I used is prime and see how many prime number there are between 1-100 and then 1-1000 (168 primes) and so on. The thing that I need to do is find the number of prime numbers between 101-200, 201-300, 301-400, and so on until 901-100 and have it show on screen. Here is the exact assignment that I’m supposed to find out:
Assignment:
Write a C++ program to calculate and display the number of primes from 1 to 100,000, separated in groups of 100, 10 groups per line. To be more precise, on the first line of output, display the number of primes between 1 and 100, 101 and 200, etc., up to 901 to 1000. Then display the average primes per group. For example, there are 168 primes from 1 to 1000, so the average number of primes per group of 100 (or percentage) is 16.8. Then repeat the process for the groups of 100 between 1001 to 1100, 1101 to 1200, etc., for all groups of 1000 all the way up to 100,000. Your results should be as presented below, under testing.
Testing:
The output of your program should be the following, according to my calculations. Each group (g1, g2, etc.) is the number of primes in a group of 100 numbers. For example in line 1, g1 is the group from 1 to 100, g2 is the group 101 to 200, etc. For line 2, g1 is the group 1001 to 1100, g2 is 1101 to 1200, and g10 is the group from 1901 to 2000.
g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 Average Primes
----------------------------------------------------------------
25 21 16 16 17 14 16 14 15 14 16.8 for 1 to 1000
16 12 15 11 17 12 15 12 12 13 13.5 for 1001 to 2000
14 10 15 15 10 11 15 14 12 11 12.7 for 2001 to 3000
12 10 11 15 11 14 13 12 11 11 12.0 for 3001 to 4000
…
…
…
7 10 5 10 7 11 7 6 11 8 8.2 for 97001 to 98000
7 5 9 9 11 8 7 8 12 11 8.7 for 98001 to 99000
8 11 8 8 7 9 8 10 10 8 8.7 for 99001 to 100000
Total number of primes from 1 to 100000: 9592
Average primes per 1000: 95.92
Percentage of primes from 1 to 100000: 9.59
Here is my code that I have done so far:
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
bool isPrime(long candidate);
long primeCount (long start, long end);
[Code] ....
View 8 Replies
View Related
Oct 4, 2014
So far i know that the pointer is address value to the real variable. Pointer size depends on operation system right?
for example
32bit systems: 4byte pointers
64bit systems: 8byte pointers
128bit systems: 16byte pointers?
Anyways, there have to be an variable type in c++ what can hold a pointer.
Let's imagine that the int is the thing im looking for
struct stc1 {
char *chars;
int ints;
}
struct stc2 {
char *chars;
float floats;
[Code]....
My wish is to hold different types of variable or groups of different type of variables in one variable.
I am developing program in windows now yet it will be used in linux and who knows with what x bit systems.
View 2 Replies
View Related
Oct 11, 2012
Is there any methods to add scroll bar for group box
My code scenerio is: I have many groupbox in form, all group box will be appears in same place and also height and width is fixed. I'm doing group box visible true/false according to condition.
So some groupbox ecxeeds the width and heighto so I want to put this all in scroll Bar
View 2 Replies
View Related
Dec 17, 2013
How to sum groups in C++? I have a class with 2 attributes (Group and Price). I need to find the group with the highest amount. I can find the max when it comes to finding a set of individual numbers but not when a group is required. For Ex:
Group A64
Group A48
Group A18
Group B49
Group B36
Group C64
Group C75
Group C87
Group C72
The group with the highest amount is GROUP C
View 14 Replies
View Related
Dec 27, 2013
Arrays are by far the most fun to work with and I really need see if its possible to enable an array to count apples, pears, peaches, from a group of three each.
If any of the fruit groups were chosen how might an algorithm be put together to count how many were chosen from each group. But lets take into consideration that these fruit groups are not supposed to be randomly generated, instead they belong as an array with certain amount of chosen occurrences. To show how many fruits were chosen from each group example, 1 from group 1, 2 from group 2, 3 from group 3 the out put is the important part because it shows the group and the occurrence of that group. the algorithm should be able to display the group with an occurrence as well
View 1 Replies
View Related
Nov 28, 2014
Write a program that reads a group of chars till $. Then, compute # of vowels, # of digits, # of word and # of special chars. Your program should display all required results.
So in what way should I do it? Loop, array, ...?
View 13 Replies
View Related
Nov 13, 2013
I have a problem with UDP Multicast. I managed to send UDP Multicast telegrams and receive them. But when I receive the telegram I need to find out to which multicast group address it was sent. So far I have:
Code:
recvfrom( hSocket,
pcData,
nMaxDataLen,
0,
(SOCKADDR*) &from,
&len);
When I read from.sin_addr.S_un.S_addr; then I get the original IP Adresse from the sender PC but I also would like to know to which group address it was sent. Is there a way to get this infoamtion?
View 3 Replies
View Related
Mar 27, 2013
I am working on a project for school that has us read in a text file that contains 8 lines of SSN and grades. I am not sure how to go about reading in the lines and differentiate between the SSN and grades in the calculations.
View 1 Replies
View Related
Feb 13, 2013
I am suppose to make a program that will output a line for a specific age group,but everytime I execute the exe file it gives me the desired line and also the last line included everytime.Where did I go wrong with it including the last line everytime?
#include <iostream>
using namespace std;
int main() {
double age;
cout<<"Enter your age:";
cin>>age;
if (0<age && age <6)
[Code] ......
View 1 Replies
View Related
Feb 26, 2014
I need to edit ,update and display a group of 40 parameters on screen. (10 parameters per page and use of Arrow Key pad or touch screen clicks to modify value)....
For that I will need .. Parameter No . , String Name , Point Screen Cord , double value , next element no. etc I have my old code with structure and array of structure written in C. I have translated it on C++/MFC .
How can I implement Class property of c++ ?
View 8 Replies
View Related
Sep 26, 2013
I'm trying to make an array that takes a group of numbers and finds the largest number into a template class.
template<class TYPE>
void Integers(TYPE data) {
int integers[] = {4, 25, 32, 85, 150, 12, 98, 200};
int i = 0;
int Max=integers[0];
for (i=1; i < 8; i++) {
[Code] ....
I'm sure I'm going about it all wrong, but I'm not sure as to get it so that it will accept the arrays input.
View 2 Replies
View Related
Apr 9, 2013
I have a datatable which comprises values from 1st January to march, something like this:
DataTable datatable = new DataTable("Employee");
datatable.Columns.Add("Date", typeof(string));
datatable.Columns.Add("Employee", typeof(string));
datatable.Columns.Add("Job1", typeof(double));
datatable.Columns.Add("Job2", typeof(double));
datatable.Rows.Add(new Object[] { "1/4/2013", "A", 1.3, 2 });
[Code] ....
The result should look like this for Job1:
Employee 1/7-1/13 1/14-1/20 1/21-1/27 1/28-2/3 and so on...
A sum of values for this 7 days
B
C
D
I want to add all the values of Job1 for each employee in a time range which is one week starting from monday to sunday. How can I group the Job1 values week wise and store them in another datatable.
View 4 Replies
View Related
Oct 12, 2014
I'm trying to get unique elements from a set but it prints for each item all the rest, for example if i have 3 items in a set it will print 6 instead of 3. I use this code:
for (set<string>::iterator i = mails.begin(); i != mails.end(); ++i) {
cout << *i << endl;
}
Is there any way to print just the unique items from a set ?
The set contains:
1
2
3
But it will print
1
2
3
2
3
3
View 3 Replies
View Related