-
December 25th, 2004, 05:02 PM
#11
Senior Member
Code:
public class Test {
private int start = 33;
private int end = 126;
public void generateCombo() {
for (int a = start; a <= end; ++a) {
for (int b = start; b <= end; ++b) {
for (int c = start; c <= end; ++c) {
for (int d = start; d <= end; ++d) {
for (int e = start; e <= end; ++e) {
for (int f = start; f <= end; ++f) {
for (int g = start; g <= end; ++g) {
for (int h = start; h <= end; ++h) {
System.out.println((char) a + "" +
(char) b + "" + (char) c + "" +
(char) d + "" + (char) e + "" +
(char) f + "" + (char) g + "" +
(char) h);
}
}
}
}
}
}
}
}
}
public static void main(String[] args) {
Test test = new Test();
test.generateCombo();
}
}
Well, this is what i have coded. I heard of recursion and some other algorithms would be able to do the job as well. Hope someone can shed some light on me lol
-
December 25th, 2004, 05:08 PM
#12
Code:
#include <iostream>
using namespace std;
int main() {
char pw[6];
int MAXVAL = 126;
int MINVAL = 33;
// Set the string to be the first password
for (int i = 0; i < 6; i++) {
pw[i] = MINVAL;
}
int pwCount = pow(MAXVAL - MINVAL, 6);
for (i = 0; i < pwCount; i++) {
if (++pw[5] >= MAXVAL) {
pw[5] = MINVAL;
if (++pw[4] >= MAXVAL) {
pw[4] = MINVAL;
if (++pw[3] >= MAXVAL) {
pw[3] = MINVAL;
if (++pw[2] >= MAXVAL) {
pw[2] = MINVAL;
if (++pw[1] >= MAXVAL) {
pw[1] = MINVAL;
pw[0]++;
}
}
}
}
}
}
}
ZeroCool, and I with the help of another online friend were able to pull this from our asses... yes, yes, it's C++ but it runs a lot faster than Java so you can use the concept and convert it to Java.
Just curious, what would you use this for? In the end this comes to hundreds of gb of data...
-
December 25th, 2004, 06:04 PM
#13
Senior Member
Originally posted here by ;TT
Code:
#include <iostream>
using namespace std;
int main() {
char pw[6];
int MAXVAL = 126;
int MINVAL = 33;
// Set the string to be the first password
for (int i = 0; i < 6; i++) {
pw[i] = MINVAL;
}
int pwCount = pow(MAXVAL - MINVAL, 6);
for (i = 0; i < pwCount; i++) {
if (++pw[5] >= MAXVAL) {
pw[5] = MINVAL;
if (++pw[4] >= MAXVAL) {
pw[4] = MINVAL;
if (++pw[3] >= MAXVAL) {
pw[3] = MINVAL;
if (++pw[2] >= MAXVAL) {
pw[2] = MINVAL;
if (++pw[1] >= MAXVAL) {
pw[1] = MINVAL;
pw[0]++;
}
}
}
}
}
}
}
ZeroCool, and I with the help of another online friend were able to pull this from our asses... yes, yes, it's C++ but it runs a lot faster than Java so you can use the concept and convert it to Java.
Just curious, what would you use this for? In the end this comes to hundreds of gb of data...
Well, this is my assignment in school haha. Just curious about ways and ways of solving a problem =p
-
December 26th, 2004, 10:19 PM
#14
Death_Knight type out the entire specifications for your project for school. I am looking at what everyone is giving you and wondering first what the hell. Second, I don't truly understand what your professor wants you to do.
-
December 27th, 2004, 06:17 AM
#15
Senior Member
Originally posted here by whizkid2300
Death_Knight type out the entire specifications for your project for school. I am looking at what everyone is giving you and wondering first what the hell. Second, I don't truly understand what your professor wants you to do.
Sorry, i didn't specify my requirements properly and pardon me for my bad english. Anyway i have solved my problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|