How to use batch file to create random lottery numbers?

2013-11-24 10:43 am
I want to write a batch file to create 6 random lottery numbers (between 1 and 49). The most important is that the random numbers should not be repeated. Please tell me how to write the batch codes. Thank you

回答 (2)

2013-11-25 6:20 pm
✔ 最佳答案
This is a gambling section. People who have knowledge of their skills/traits often only look in the proper section their particular questions. The gambling section is the wrong section to get the answers.
2015-02-11 8:41 pm
http://stackoverflow.com/questions/12991758/creating-all-possible-k-combinations-of-n-items-in-c

#include <iostream>
#include <vector>

using namespace std;

vector<int> people;
vector<int> combination;

void pretty_print(const vector<int>& v) {
static int count = 0;
cout << "combination no " << (++count) << ": [ ";
for (int i = 0; i < v.size(); ++i) { cout << v[i] << " "; }
cout << "] " << endl;
}

void go(int offset, int k) {
if (k == 0) {
pretty_print(combination);
return;
}
for (int i = offset; i <= people.size() - k; ++i) {
combination.push_back(people[i]);
go(i+1, k-1);
combination.pop_back();
}
}

int main() {
int n = 5, k = 3;

for (int i = 0; i < n; ++i) { people.push_back(i+1); }
go(0, k);

return 0;
}


收錄日期: 2021-05-01 01:02:54
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20131124024306AA5gSl3

檢視 Wayback Machine 備份