-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (34 loc) · 1.26 KB
/
Copy pathmain.cpp
File metadata and controls
46 lines (34 loc) · 1.26 KB
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
#include <thread>
#include <iostream>
#include <vector>
// commit info
int amountOfCommitsNeeded;
int currentAmountOfCommits = 1;
void Printer() {
//starts while loop for commits
while (currentAmountOfCommits < amountOfCommitsNeeded)
{
// the command being executed
std::string str = "git commit --allow-empty -m \"Commit " + std::to_string(currentAmountOfCommits) + " out of " + std::to_string(amountOfCommitsNeeded) + "\"";
// coverting the command to a c string and exeuting it
system(str.c_str());
// adding +1 to the amount of commits
currentAmountOfCommits++;
}
}
int main() {
// asks for amount of commits
std::cout << "Enter Amout Of Commits: ";
std::cin >> amountOfCommitsNeeded;
//asks for amount of threads
std::cout << "Enter Amout Of Threads: ";
int threadAmount;
std::cin >> threadAmount;
// creates array for threads and joins the threads
std::vector<std::thread> ThreadContainer;
for (int i = 0; i < threadAmount; i++) ThreadContainer.push_back(std::thread(Printer)); // adds values to array
for (int i = 0; i < ThreadContainer.size(); i++) ThreadContainer[i].join(); // joins threads
// print result
std::cout << "Done! The Final Result: " << currentAmountOfCommits << std::endl;
return 0;
}