-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cpp
53 lines (45 loc) · 1.45 KB
/
Program.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
53
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include <boost/format/format_fwd.hpp>
#include <iostream>
#include <string>
#include <vector>
struct Occourencies {
char character;
std::string visualizer;
int occour;
public:
Occourencies(char character, std::string visualizer, int occour) {
this->character = character;
this->visualizer = visualizer;
this->occour = occour;
}
};
std::vector<Occourencies> occChecker(std::string myString, std::string chars) {
int occFound{0};
std::string visualizer;
std::vector<Occourencies> occ;
boost::to_lower(myString);
for (int y = 0; y < chars.length(); y++) {
for (int z = 0; z < myString.length(); z++) {
if (myString[z] == chars[y]) {
occFound += 1;
visualizer.append("*");
}
}
occ.push_back(Occourencies(chars[y], visualizer, occFound));
occFound = 0;
visualizer.clear();
}
return occ;
};
int main() {
std::string myString{"abbccdeefffggghiijjkklllmnoppqrrstuvvvvvvwwwwwwwxxyyzz !/?.,=+-_%"};
std::string chars{"abcdefghijklmnopqrstuvwxyz1234567890!§$%&/()=?"};
std::vector<Occourencies> occ{occChecker(myString, chars)};
std::cout << boost::format("String: %1%\n") % myString << std::endl;
std::cout << boost::format("%-50s %-20s\n") % "Zeichen" % "Vorkommen";
for(auto i = 0; i < occ.size(); i++) {
std::cout << boost::format("%-50s %-10s %-20s\n") % occ[i].character % occ[i].occour % occ[i].visualizer;
}
};