Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4. #include <vector>
  5. using namespace std;
  6. //vector <token*> vect;
  7.  
  8. //class token {
  9. //
  10. //};
  11. //
  12. //class word : public token{
  13. //public:
  14. // string stringg;
  15. //
  16. //};
  17. //
  18. //class num : public token{
  19. //public:
  20. // int n;
  21. //};
  22. //void input(vector <token*> &vect) {
  23. // vect.push_back(new word);
  24. // vect.push_back(new num);
  25. //}
  26. //void split(int s, vector <token*>& vect) {
  27. // for (int i = 0; i < s.size(); i++) {
  28. // if (int(s[i]) > 47 & int(s[i])<58)
  29. //
  30. // }
  31. //
  32. //}
  33.  
  34. class Box {
  35. public:
  36. vector<int*>v_num;
  37. vector<string*>v_word;
  38. };
  39.  
  40. void split(string s, Box &db) {
  41. for (int i = 0; i < s.size();)
  42. {
  43. if (s[i] >= '0' && s[i] <= '9') {
  44. db.v_num.push_back(new int(s[i]));
  45. i++;
  46. }
  47. else {
  48. if (s[i] == ' ')
  49. i++;
  50. else {
  51. db.v_word.push_back(new string);
  52. *db.v_word[db.v_word.size() - 1] = s[i];
  53. i++;
  54. }
  55. }
  56. }
  57. }
  58.  
  59. void print(Box db) {
  60. for (int i = 0; i < db.v_word.size() ; i++) {
  61. cout << *db.v_word[i];
  62. }
  63. }
  64.  
  65. int main()
  66. {
  67. Box DB;
  68. setlocale(LC_ALL, "rus");
  69. string s = "Имя 145 фамилия 7495 и отчество ";
  70. split(s, DB);
  71. //s1 += s[i];
  72. print(DB);
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement