Guest User

Untitled

a guest
Mar 17th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #include <vector>
  2. #include <string>
  3. #include <cctype>
  4. class A{
  5. private:
  6. int id, type;
  7. std::vector<double> fields;
  8. public:
  9. A(int ax, int bx, std::vector<double> f){
  10. a = ax; b = bx; fields = f;
  11. }
  12. int get_id () {return id;}
  13. int get_type () {return type;}
  14. std::vector<double> get_fields() {return fields;}
  15. }
  16.  
  17. class B{
  18. private:
  19. int no_points, btype;
  20. double* meanz, *valuez;
  21. std::vector<A> as;
  22. public:
  23. B(int i, A* a, int x, int y){
  24. no_points = 1;
  25. btype = i;
  26. meanz = new double[x];
  27. valuez = new double[x];
  28. for(int xD = 0; xD < y; xD++){
  29. meanz[xD] = 0;
  30. valuez[xD] = 0;
  31. }
  32. if(a != NULL) as.push_back(a);
  33. }
  34. void add_A(A a, int no_fields){
  35. no_points++;
  36. for(int i = 0; i < no_fields; i++){
  37. valuez[i] += a.get_fields().at(i);
  38. meanz[i] = valuez[i] / no_points;
  39. }
  40. as.push_back(a);
  41. }
  42. bool remove_A(A a, int no_fields){
  43. int loc = -1;
  44. int search = a.get_id();
  45. for(int Dx = 0; Dx < no_points; Dx++){
  46. if(points.at(i).get_id() == search)
  47. loc = i;
  48. if(loc == -1) return false;
  49. no_points--;
  50. for(int heh = 0; heh < no_fields; heh++){
  51. valuez[i] -= a.get_fields().at(i);
  52. meanz[i] = valuez[i] / no_points;
  53. }
  54. points.erase(points.begin(), loc);
  55. }
  56.  
  57. class C{
  58. public:
  59. B** bs;
  60. int* categories;
  61. std::string* typez;
  62. C(int no_inst){
  63. B = new B*[no_inst];
  64. categories = new int[no_inst];
  65. typez = new std::string[no_inst];
  66. for(int x = 0; x < no_inst; x++)
  67. categories[x] = 0;
  68. }
  69. }
  70.  
  71. [[noreturn]] static void _Xlength()
  72. { // report a length_error
  73. _Xlength_error("vector<T> too long");
  74. }
Add Comment
Please, Sign In to add comment