diff --git a/.idea/magicCards.iml b/.idea/magicCards.iml index bc2cd87409057301f546d83bd548111b9a241cb1..f08604bb65b25149b195f9e9f282f9683a428592 100644 --- a/.idea/magicCards.iml +++ b/.idea/magicCards.iml @@ -1,8 +1,2 @@ <?xml version="1.0" encoding="UTF-8"?> -<module type="CPP_MODULE" version="4"> - <component name="NewModuleRootManager"> - <content url="file://$MODULE_DIR$" /> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - </component> -</module> \ No newline at end of file +<module classpath="CMake" type="CPP_MODULE" version="4" /> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/main.cpp b/main.cpp index bc8f460d02aeb0695e7840121bc4caefe788a878..5e094c5697cc9ea2150152dca1b166e6f0ae81bf 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,65 @@ #include <iostream> +#include <cstring> +#include <algorithm> +#include <string> + +class Cards { +public: + Cards() = default; + Cards(std::string name, int mana, int cmc, std::string type, int count) + : m_name(std::move(name)), m_mana(mana), m_cmc(cmc), m_type(std::move(type)), m_count(count) + {} + + const std::string& getName() const { return m_name; } + int getMana() const { return m_mana; } + int getCMC() const { return m_cmc; } + const std::string& getType() const { return m_type; } + int getCount() const { return m_count; } + + void setName(const std::string& name) { m_name = name; } + void setMana(int mana) { m_mana = mana; } + void setCMC(int cmc) { m_cmc = cmc; } + void setType(const std::string& type) { m_type = type; } + void setCount(int count) { m_count = count; } + +private: + std::string m_name; + int m_mana; + int m_cmc; + std::string m_type; + int m_count; +}; + +int levenshteinDistance(const char *s1, const char *s2) { + const int len1 = std::strlen(s1); + const int len2 = std::strlen(s2); + + int matrix[len1 + 1][len2 + 1]; + + for (int i = 0; i <= len1; i++) { + matrix[i][0] = i; + } + for (int j = 0; j <= len2; j++) { + matrix[0][j] = j; + } + + for (int i = 1; i <= len1; i++) { + for (int j = 1; j <= len2; j++) { + const int cost = (s1[i - 1] == s2[j - 1]) ? 0 : 1; + matrix[i][j] = std::min({ matrix[i - 1][j] + 1, + matrix[i][j - 1] + 1, + matrix[i - 1][j - 1] + cost }); + } + } + return matrix[len1][len2]; +} int main() { - std::cout << "Hello, World!" << std::endl; + const char* str1 = "kitten"; + const char* str2 = "sitting"; + const int distance = levenshteinDistance(str1, str2); + + std::cout << distance << std::endl; + return 0; }