Generating unique random numbers in a multi dimensional array in C++ [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am trying to create a 3x5 two dimensional array that contains the values 1-15 in a randomized order so that each number will only be used once.

Generate a vector or array containing the numbers 1-15 and then use std::random_shuffle, putting the result in your array.

I would suggest using boost random and using the uniform int or uniform small int distribution

Related

Regular expression in asp.net, containing either two fixed alphabets(D and DQ) or any two numbers [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to validate a text box (with max length 2) to contain only these 3 set of values.
(i) 00-99
(ii) Q
(iii) DQ
Invalid values are 1Q, 2D, QD, QQ, DD,etc etc
Alright you can use the following it will check for what you asked for its very simple and primitive regix but will work:
\d{2}|DQ|Q
If you want to better understand regular expressions the following might help:
http://msdn.microsoft.com/en-us/library/az24scfc.aspx
You can also use:
http://myregextester.com/index.php
As a tool to test your regix.
Hope that helps

How to create a random 160 bit prime number in C++? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am working on a project in school and I need to create a 160 bit value. I haven't programmed in a while so I can't figure out how I would implement this. Any help would be appreciated.
You need a library for big integers (assuming you can't just take a ready-to-use cryptographic library).
First you create a random 160-bit value, not necessarily prime. Depending on the platform, you may use /dev/random, CryptGenRandom, or some other enthropy source(s), (possible several ones, combined).
Then you increment the value in a loop, applying e.g. Miller-Rabin (pseudo-)primality test to each candidate, until you find a prime number.

Upto how many numbers next_permutation (given in CPP <algorithm>)works? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am using next_permutation in cpp (algorithm library). What is the upper limit on the length of the string which it can permute? As i can permute a string of length 5 easily but for length 50 it's just do not stop. I know 50! is quite large so i want to know if there is some reasonable limit on it's usage.
Well it works for as many numbers as your memory will fit. It simply takes longer. And by longer I mean that for 50! you will have to wait about 96442456880115988215412887386050129516671872047 years on a contemporary computer or a lot of orders of magnitute longer then the universe is supposed to exist.

How do I make a smaller range with two given integers? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
For example,
I have a range 14269-14274.
To conserve space on the screen my users want to have it display in the format 14269-74.
Another example would be a range of 14269-14529 which should output as 14269-529.
How would I achieve this?
Something like this should do the trick:
int a = 14269;
int b = 14529;
int endrange = b % pow(10, floor(log10(b - a) + 1));
You need to make sure that a < b though.
You can check the first digit that differs, output the first number and then the second one, starting at the first different digit.
This of course only makes sense if the two numbers have the same length.
Were you expecting the implementation?

Data structures for huge graphs in C++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I want to understand how huge graphs can be implemented, so that graph algorithms run faster with huge graphs.
Maybe you should look at a famous graph library, e.g. boost graph library
The core idea for graph representation is incidence matrix. The rest depends on what you need. For example possible solution oriented on quickly finding neighbours are adjacency matrices.