Advertisement
Stefoto_24

Untitled

Jan 22nd, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. //Header file start
  2. #pragma once
  3. #include <iostream>
  4.  
  5. //Задача 1
  6. int* histogram(char*, char*);
  7.  
  8. //Header file end
  9.  
  10. //Functions file start
  11. #include "HeaderForCA5.h"
  12. #include <iostream>
  13.  
  14. using namespace std;
  15.  
  16. int* histogram(char* setU, char* setA)
  17. {
  18. int sizeU = strlen(setU);
  19. int sizeA = strlen(setA);
  20.  
  21. int* temp = NULL;
  22. temp = new int[20];
  23.  
  24. int count = 0;
  25. for (int i = 0; i <= sizeU; i++)
  26. {
  27. for (int j = 0; j <= sizeA; j++)
  28. {
  29. if (setU[i] == setA[j])
  30. {
  31. count++;
  32. }
  33. }
  34. temp[i] = count;
  35. count = 0;
  36. }
  37.  
  38. return temp;
  39. }
  40.  
  41. //Function file end
  42.  
  43. //Main file start
  44. #include "HeaderForCA5.h"
  45. #include <iostream>
  46. #include <cstdlib>
  47.  
  48. using namespace std;
  49.  
  50. int main()
  51. {
  52. system("chcp 1251 > null");
  53.  
  54. //Задача 1
  55. int* histo = NULL;
  56. histo = new int[20];
  57.  
  58. char* setU = NULL;
  59. setU = new char[20];
  60.  
  61. char* setA = NULL;
  62. setA = new char[100];
  63.  
  64. cout << "Въведете елементи нна универсалното множество: ";
  65. cin.getline(setU, 20);
  66.  
  67. cout << "\nВъведете текст: ";
  68. cin.getline(setA, 100);
  69.  
  70. histo = histogram(setU, setA);
  71.  
  72. for (int i = 0; i < 20; i++)
  73. {
  74. cout << "[" << setU[i] << "] - " << histo[i] << '\n';
  75. }
  76. }
  77.  
  78. //Main file end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement