Please I need help with a simple code !

hello there, I need help implementing with a simple code
I am trying to generate multiple Different tickets, so far my code generates tickets but they are all the same, how do I change that, I would appreciate any help .


#include <iostream>
#include <stdio.h> /* printf, scanf, puts, NULL */
#include <stdlib.h> /* srand, rand */


using namespace std;

int main()
{
int min_ticket , max_ticket ;
int n1, n2, n3, n4, n5, n6;
cout << "Enter Minimum no. of ticket to be generated : ";
cin >> min_ticket;
cout << "Enter Maximum no. of ticket to be generated : ";
cin >> max_ticket;
int ticknum = min_ticket + rand() % (max_ticket - min_ticket);
cout << ticknum << endl;




//int n1, n2, n3, n4, n5, n6;


for (int c = 0; c < ticknum; c++)
{
n1 = 1 + (rand() % 47);
n2 = 1 + (rand() % 47);
n3 = 1 + (rand() % 47);
n4 = 1 + (rand() % 47);
n5 = 1 + (rand() % 47);

if (n1 != n2 && n1 != n3 && n1 != n4 && n1 != n5 &&
n2 != n3 && n2 != n4 && n2 != n5 &&
n3 != n4 && n3 != n5 && n4 != n5) {
break;
}
}

for (int i = 0; i < ticknum; i++)
{
n6 = 1 + (rand() % 27);
}
for (int i = 0; i < ticknum; i++)
{
cout << "Ticket " << n1 << " " << n2 << " " << n3 << " " << n4 << " " << n5 << " " << n6 << endl;
}

return 0;
}
closed account (48T7M4Gy)
.
Last edited on
how do I use the code tags?
closed account (48T7M4Gy)
Don't double post and waste our time by duplicating effort
http://www.cplusplus.com/forum/general/177567/
Last edited on
I am sorry but I am new here, I didn't mean to post it twice because I thought I posted my original question in the wrong forum and that's why no one has answered me, I apologize and thanks.
closed account (48T7M4Gy)
OK we all make mistakes. I suggest you use the other post where all the other work is to be seen. There is no danger of your posts not being seen.
thank you. how do I delete this post?
also can you show me how to use the code tags, I would truly I appreciate it.
closed account (48T7M4Gy)
Don't worry about it. I don't think u can. Go to your other site.

Code tags are shown as <> in the tool box on the right when you're typing up your post
Select the text u want and hit the <> button.

:)
Topic archived. No new replies allowed.