31 lines
503 B
C++
31 lines
503 B
C++
#include <map>
|
|
#include <iostream>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
if(argc < 2)
|
|
{
|
|
std::cout << "Usage: " << argv[0] << " <ciphertext>" << std::endl;
|
|
return 0;
|
|
}
|
|
char* ciphertext = argv[1];
|
|
std::map<char, int> letters;
|
|
|
|
for(int i = 0; ciphertext[i] != 0; ++i)
|
|
{
|
|
if(letters.contains(ciphertext[i]))
|
|
{
|
|
letters[ciphertext[i]]++;
|
|
}
|
|
else
|
|
{
|
|
letters[ciphertext[i]] = 1;
|
|
}
|
|
}
|
|
for(auto& [key, value] : letters)
|
|
{
|
|
std::cout << key << ": " << value << std::endl;
|
|
}
|
|
return 0;
|
|
}
|