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?
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);
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?
I am storing info in a vector but I want to store certain info at a particular index. I am new to using vectors and am unsure about have to do this. I am aware of the insert method but am confused on how to use it to store at a particular index.
Consider I have a vector of strings and then I use an istringstream to read each word of each element in the vector, why do I nescessarily use an istringstream?
This is the code that does what I just described (I think)..
I am programming a 2-D platformer video game. The stages are composed of an array (really a vector) of 16x16 px^2 tiles. I have defined a base class "Tile" and several derived classes, e.g., "Ramp", "Door", etc., which have their own attributes. The idea is that upon entering a room, the program will load all of the necessary tile data for that room into a vector. So, I have a vector that looks like: vector <Tile*> room_tiles, and resize it based on the total number of tiles in the room: room_tiles.resize(Tile_Count). I then want to read in certain info from the data file containing all of the tile information for that room. For example, if the data file says Tile 5 should be a ramp, I want to change the 5th element of the room_tiles vector to the derived ramp class. This is really where I'm having trouble. I've worked with vectors of base and derived classes before, but those were always of indeterminate size and I always used something like: (Vector).push_back(new DerivedClass()) to specify the derived class of that element. The problem is that that method only seems to work if you are appending elements to the end of a vector.
I'm having a problem filling a vector from a file. Basically, it is adding an empty element at the end. I'm new to Qt and haven't worked with file streams much so how to stop the stream before it adds the extra element.
But, if I add another element to the vector and write that the file look like this.
//file after adding element 132654 0 02132014 132654 0 02132014 0 0 132998 22 02202014
I have it set to append at the moment so that is why the first line is repeated. I figure the problem is with if(in.atEnd()). I could fix it by deleting the last element right after adding it, but that seems like more of a hack than anything else.
I want to sequentially remove one element at a time starting with the first. When the second element is removed, the first element needs to go back in. The sequence would look like
Code: // original vector, row_numbers.size()=9 row_numbers{1,2,3,4,5,6,7,8,9}; // trimmed vector, row_numbers_trim.size()=8
[Code] .......
I have been working under the assumption that the best method would be to have row_numbers remain untouched and work on a copy. For each step in the sequence, you would create row_numbers_trim as a copy of row_numbers, and then remove an element from row_numbers_trim.
Code: // position being removed int counter = 0; // copy original vector row_numbers_trim = row_numbers; // remove the first element from the copy row_numbers_trim(row_numbers_trim.begin()+counter);
All you would have to do here is to increment counter in a loop. is there a better way?
I created program that insert employes data and then print their data but never accept duplicate age if user entered duplicated age prompt him to enter another age (age must be unique)
I am having a problem with the duplication of a line I'm outputting from a file. Whenever I run the program the last line in the "New accounts" portion is always repeated. Here is my code for reference:
So I have linked list and function which deletes element if next element is bigger, so my code is working but its not working with first element, in the comment I have wrote code which I would code for checking that first element, but when ever I check it is blowing up all program.
#include <iostream> using namespace std; struct llist { int x; llist *next;
This part of the code i suppose to get generate all possible combination of number and numbers and combination can't repeat. There 6 set of numbers the first 5 can't repeat, here is what I have so far. Its not efficient and is time consuming for my PC. probably will take upto 10 minutes to complete.
#include <iostream> // std::cout #include <algorithm> // std::next_permutation, std::sort int main () { int myints[] = {1,2,3}; std::sort (myints,myints+3); std::cout << "The 3! possible permutations with 3 elements:
[Code] ....
this will result
123 132 213 231 312 321
The question is : If I want to get a permutation combination with range of N
What should i do?
if N = 2 result should be 12,13,21.....such and such
Eliminate the last digit is working for 3 combination but if its going to a bigger number it does not work ...
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
I have been struggling with this program. I am somewhat new to c and suck at logic. I have a personal program I want to make that I will try to get extra credit for in school. I have a printed set of winning lottery numbers form the last 10 years. I chose the easiest one do do logically which is just 5 numbers none repeating.
I am trying to find out how I can print the least common 10 sets. I think if there are any set which have not been picked I would have to print all of those because logically they would all be equal, then print sequentially the sets least picked up to 10.
I have pseudocode which I am sure is wrong but will post it just to show that I am trying. My first attempt was to add the numbers but quickly realized that that wouldn't work ...
5 Nums Pseudocode Code: Read Nums Parse Into Ints Make Array [185] //39+38+37+36+35 The highest the numbers added together can go
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.
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.