Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _H_FUNCTIONS_H_
- #define _H_FUNCTIONS_H_
- int returnMostOccuringSym(char *, unsigned);
- #endif
- #include "functions.h"
- #include <iostream>
- #include <time.h>
- int returnMostOccuringSym(char * string, unsigned size)
- {
- char ch = string[0];
- int occures = 0;
- int max = 0;
- for (size_t i = 1; i < size; i++)
- {
- for (size_t k = 0; k < size; k++)
- {
- if (ch == string[k])
- {
- occures++;
- }
- }
- if (occures > max)
- {
- max = occures;
- }
- }
- return 0;
- }
- #include "functions.h"
- #include <iostream>
- using namespace std;
- int main() {
- int size;
- cout << "Enter the size of string" << endl;
- cin >> size;
- char * string = new char[size];
- for (int i = 0; i < size; i++)
- {
- int randomVal = rand() % 256 + 1;
- string[i] = randomVal;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement