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

reset

parent fccefbb1
No related branches found
No related tags found
No related merge requests found
#include <iostream> #include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
class Cards { int main()
public: {
Cards() = default; std::cout << "Info 3 Projekt Nr.1" << std::endl;
Cards(std::string name, int mana, int cmc, std::string type, int count) return 0;
: m_name(std::move(name)), m_mana(mana), m_cmc(cmc), m_type(std::move(type)), m_count(count) }
{} \ No newline at end of file
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() {
const char* str1 = "kitten";
const char* str2 = "sitting";
const int distance = levenshteinDistance(str1, str2);
std::cout << distance << std::endl;
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