👤

Siemka mam tu zadanie z c++, kompletnie nie ogarniam tego programu i potrzebuje pomocy z dwoma zadaniami. Wszystko w pliku, z góry dziekuje

Odpowiedź :

Odpowiedź:

#include<iostream>

using namespace std;

string dots(string word)

{

   for (int i = 0; i < word.length(); i+=1)

       if (word[i] == 'u' || word[i] == 'h' || word[i] == 'o' || word[i] == 'z')

           word[i] = '*';

   return word;

}

int main()

{

   string word = "";

   cout << "Wyraz: ";

   cin >> word;

   cout << dots(word);

   return 0;

}

------------------------------------------------------------------

#include<iostream>

using namespace std;

int nothamming(string word1, string word2)

{

   int h = 0;

   for (int i = 0; i < word1.length(); i++) {

       if (word1[i] == word2[i]) {

           h++;

       }

   }

   return h;

}

int main()

{

   string word1 = "";

   string word2 = "";

   cout << "Wyraz 1: ";

   cin >> word1;  

   cout << "Wyraz 2: ";

   cin >> word2;

   cout << nothamming(word1, word2);

   return 0;

}

Wyjaśnienie: