470,831 Members | 1,545 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,831 developers. It's quick & easy.

if some one could help me with this im a noobie

first off i'd like to say i'm vary new at programming and i don't want this but it's my brother that dose its the only thing he asked for, for christmas so please don't make rude comments.
what im trying to do is make a program that would calculate all possible combinations. of numbers from 1-54 basicly he wants all the possible lottery number combinations.i thought it would be easy at first so i said yes to it and i don't want to disapoint him.any way this is what i have so far (below ex 1), the problem is that i dont know how to do it any other way and basicly all it dose is count up to it. i thought that maybe if i just change some of the variables it would do it that way but didn't ( by the way i'm just going over this to tell you what i've already tried so bear with me )then i tried a vector and i couldn't even compile it right that should tell you how new i am at this.so i would appreciate
any help you can give me.
[HTML](ex 1)
#include <iostream>
#include <fstream>

using namespace std;

int main(){
int a,b,c,d,e,f,g,h,i,j;
int max = 54;
for(a=0;a<max;++a){
for(b=0;b<max;++b){
for(c=0;c<max;++c){
for(d=0;d<max;++d){
for(e=0;e<max;++e){
for(f=0;f<max;++f){
cout <<a<<""<<b<<""<<c<<""<<d<<""<<e<<""<<f<<endl;
}}}}}}
}[/HTML]
[HTML](ex 2)
#include <iostream>
#include <vector>

typedef std::vector <int>::size_type sz_t;
typedef unsigned digit_t;

const sz_t size = 10;
const digit_t modulus = 101;

std:stream &
operator << (std:stream & s, const std::vector <digit_t> & v)
{
for (sz_t i = 0, n = v.size (); i != n; ++ i)
(i ? (s << ", ") : s) << v [i];
return s;
}

int main ()
{
std::vector <digit_t> v (size);
while (v.back () != modulus)
{
std::cout <<v<<\n;
++ v.front ();
for (sz_t i = 0; i != size - 1; ++ i) if (v [i] == modulus)
{
v [i] = 0;
++ v [i + 1];
}
}
}[/HTML]
Nov 28 '06 #1
0 901

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by neilphan | last post: by
6 posts views Thread by Aristotelis E. Charalampakis | last post: by
reply views Thread by 7Percent | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.