Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- char naiSreshtanaBukva(char* bukvi, char* string, int* broqchi, int razmerNaMnoj, int razmerNaString)
- {
- int poz = 0;
- int tempBiggest = 0;
- for (int i = 0; i < strlen(string); i++) {
- for (int j = 0; j < strlen(bukvi); j++) {
- if (bukvi[j] == string[i])
- {
- broqchi[j] = broqchi[j] + 1;
- continue;
- }
- }
- }
- for (int i = 0; i < razmerNaMnoj; i++)
- {
- if (broqchi[i] > tempBiggest)
- {
- tempBiggest = broqchi[i];
- poz = i;
- }
- }
- char naiSreshtana = bukvi[poz];
- return naiSreshtana;
- }
- void newStringL(char* mnojString, int razmer, char naiSreshtanaBukva)
- {
- for (int i = 0; i < razmer; i++)
- {
- if (mnojString[i] == naiSreshtanaBukva) {
- mnojString[i] = '!';
- }
- }
- cout << mnojString;
- }
- int main()
- {
- char mnojestvoBukvi[] = { 't','m','o','e','\0' };
- char mnojestvoStringove[] = { "This is a test string!" };
- cout << endl << "String: " << mnojestvoStringove << endl;
- int* broqch = new int[strlen(mnojestvoStringove)];
- for (int i = 0; i < strlen(mnojestvoStringove); i++) {
- broqch[i] = 0;
- }
- char biggestMet = naiSreshtanaBukva(mnojestvoBukvi, mnojestvoStringove, broqch, strlen(mnojestvoStringove), strlen(mnojestvoStringove));
- newStringL(mnojestvoStringove, strlen(mnojestvoStringove), biggestMet);
- delete[]broqch;
- broqch = NULL;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement