Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Header file start
- #pragma once
- #include <iostream>
- //Задача 1
- int* histogram(char*, char*);
- //Header file end
- //Functions file start
- #include "HeaderForCA5.h"
- #include <iostream>
- using namespace std;
- int* histogram(char* setU, char* setA)
- {
- int sizeU = strlen(setU);
- int sizeA = strlen(setA);
- int* temp = NULL;
- temp = new int[20];
- int count = 0;
- for (int i = 0; i <= sizeU; i++)
- {
- for (int j = 0; j <= sizeA; j++)
- {
- if (setU[i] == setA[j])
- {
- count++;
- }
- }
- temp[i] = count;
- count = 0;
- }
- return temp;
- }
- //Function file end
- //Main file start
- #include "HeaderForCA5.h"
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- system("chcp 1251 > null");
- //Задача 1
- int* histo = NULL;
- histo = new int[20];
- char* setU = NULL;
- setU = new char[20];
- char* setA = NULL;
- setA = new char[100];
- cout << "Въведете елементи нна универсалното множество: ";
- cin.getline(setU, 20);
- cout << "\nВъведете текст: ";
- cin.getline(setA, 100);
- histo = histogram(setU, setA);
- for (int i = 0; i < 20; i++)
- {
- cout << "[" << setU[i] << "] - " << histo[i] << '\n';
- }
- }
- //Main file end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement