-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawLots.cpp
52 lines (44 loc) · 1.21 KB
/
drawLots.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
freopen("input.txt", "r", stdin);
srand(time(NULL));
vector<string> names, copyNames;
string name;
int problemNum, peopleNum;
char overlap;
cout << "인원수를 입력해주세요\n";
cin >> peopleNum;
cout << "사람의 이름을 입력해 주세요\n";
for (int i = 0; i < peopleNum; i++)
{
cin >> name;
names.push_back(name);
}
cout << "문제의 개수를 입력해주세요\n";
cin >> problemNum;
cout << "중복이 가능합니까? (Y이외에는 전부 N)\n";
cin >> overlap;
if (overlap == 'Y' || overlap == 'y')
{
for (int i = 0; i < problemNum; i++)
{
cout << i + 1 << "번문제는 " << names[rand() % names.size()] << "입니다\n";
}
}
else
{
for (int i = 0; i < problemNum; i++)
{
if (copyNames.size() == 0)
copyNames = names;
int temp = rand() % copyNames.size();
cout << i << "번문제는 " << copyNames[temp] << "입니다\n";
copyNames.erase(copyNames.begin() + temp);
}
}
}