Advertisement
Sonita

Untitled

Apr 26th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <string.h>
  5. #include <iostream>
  6. using namespace std;
  7. class Slovo {
  8. public:
  9. char Name[30];
  10. int len;
  11. char *getName() {
  12. return Name;
  13. }
  14. int getLen() {
  15. return len;
  16. }
  17. void initz(char *name,int Len);
  18. int counter();
  19. };
  20. void Slovo::initz(char *name, int Len) {
  21. strcpy_s(Name, name);
  22. len = Len;
  23. }
  24. int Slovo::counter() {
  25. char c;
  26. int cnt = 0;
  27. for (int i = 0; i < len; i++) {
  28. if (c==Name[i])
  29. cnt++;
  30. }
  31. return cnt;
  32. }
  33. void main()
  34. {
  35. char c;
  36. setlocale(0, "russian");
  37. Slovo B;
  38. Slovo C[3];
  39. cout << "Введите слово и его длину" << endl;
  40. cin >> B.Name;
  41. cin >> B.len;
  42. B.initz(B.Name,B.len);
  43. cout << B.getName() <<" "<< B.getLen() << endl;
  44. cout << "Введите букву" << endl;
  45. cin >> c;
  46. cout<<B.counter();
  47. _getch();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement