Skip to content
Snippets Groups Projects
Commit fccefbb1 authored by artemSaenger's avatar artemSaenger
Browse files

a1 & a2

parent 27507179
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4"> <module classpath="CMake" type="CPP_MODULE" version="4" />
<component name="NewModuleRootManager"> \ No newline at end of file
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?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
#include <iostream> #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() { 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; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment