From fccefbb16d63b340609e037ba51eafe5b32383b1 Mon Sep 17 00:00:00 2001
From: artemSaenger <artem.saenger@icloud.com>
Date: Thu, 13 Apr 2023 16:52:04 +0200
Subject: [PATCH] a1 & a2
---
.idea/magicCards.iml | 8 +-----
.idea/vcs.xml | 6 +++++
main.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 67 insertions(+), 8 deletions(-)
create mode 100644 .idea/vcs.xml
diff --git a/.idea/magicCards.iml b/.idea/magicCards.iml
index bc2cd87..f08604b 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 0000000..35eb1dd
--- /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 bc8f460..5e094c5 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;
}
--
GitLab