Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <cstring>
  2. #include <cstdlib>
  3.  
  4.  
  5. struct Car
  6. {
  7. char nn[10];
  8. // Добавить необходимые поля структуры
  9. };
  10.  
  11. class DB
  12. {
  13. struct Car *data_ptr = nullptr;
  14. int size=0, capacity=0;
  15.  
  16. public:
  17. DB()
  18. {
  19. data_ptr = new Car[5];
  20. capacity = 5;
  21. }
  22. // Реализовать методы добавления машинки в массив и поиска.
  23. };
  24.  
  25. struct Command
  26. {
  27. int time = 0;
  28. char car_nn[10];
  29. char type = '!';
  30. };
  31. // 02:31 * hdsgjf
  32. // 0:0 =
  33. Command parser(char *str)
  34. {
  35. Command test;
  36. long h, m;
  37. h = strtol(str, &str, 10);
  38. if (*str != ':') return test;
  39. m = strtol(str + 1, &str, 10);
  40.  
  41. // Проверка на корректность времени
  42.  
  43. ++str;
  44. if (*str == '=' && h == 0 && m == 0)
  45. {
  46. test.type = '=';
  47. return test;
  48. }
  49. if (*str == '*' && *(str + 1) == ' ')
  50. {
  51. test.time = h * 60 + m;
  52. test.type = '*';
  53. strcpy_s(test.car_nn, str + 2);
  54. }
  55. return test;
  56. }
  57.  
  58. void main()
  59. {
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement