Advertisement
Guest User

asd

a guest
Apr 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <iostream.h>
  4. #include <vcl.h>
  5. #include <string.h>
  6. #pragma hdrstop
  7.  
  8. //---------------------------------------------------------------------------
  9.  
  10. #pragma argsused
  11. class point{
  12. private:
  13. int x, y;
  14. public:
  15. point(int xi, int yi): x(xi), y(yi){}
  16. point(): x(0), y(0){}
  17. void set_x(int fx)
  18. {
  19. x = fx;
  20. }
  21. void set_y(int fy)
  22. {
  23. y = fy;
  24. }
  25. void inc_x()
  26. {
  27. x++;
  28. }
  29. void inc_y()
  30. {
  31. y++;
  32. }
  33. void dec_y()
  34. {
  35. y--;
  36. }
  37. void dec_x()
  38. {
  39. x--;
  40. }
  41. int ret_x(){
  42. return x;
  43. }
  44. int ret_y(){
  45. return y;
  46. }
  47. void ret_cord(){
  48. cout << "(" << x << "; " << y << ")" << endl;
  49. }
  50. void addPoint(point &dt){
  51. x += dt.x;
  52. y += dt.y;
  53. dt.y = y;
  54. dt.x = x;
  55. }
  56. void subPoint(point &dt){
  57. x -= dt.x;
  58. y -= dt.y;
  59. dt.y = y;
  60. dt.x = x;
  61. }
  62. void mulPoint(point &dt){
  63. x *= dt.x;
  64. y *= dt.y;
  65. dt.y = y;
  66. dt.x = x;
  67. }
  68. void divPoint(point &dt){
  69. if(dt.x!=0)
  70. x /= dt.x;
  71. if(dt.y!=0)
  72. y /= dt.y;
  73. dt.y = y;
  74. dt.x = x;
  75. }
  76. };
  77.  
  78. class parceCord{
  79. private:
  80. std::string raw, buffer, buffer1, command;
  81. unsigned int i;
  82. int xData, yData;
  83.  
  84. public:
  85. parceCord(): i(0), raw(""), buffer(""), xData(0), yData(0){}
  86. void parceInp(std::string str){
  87. raw = str;
  88. }
  89.  
  90. void parceS(std::string str){
  91. buffer = str;
  92. if(str == "")
  93. buffer = raw;
  94. i = 0;
  95. buffer1 = "";
  96. while(i < buffer.length()){
  97. while(buffer[i] == ' ')
  98. buffer.erase(i, 1);
  99. i++;
  100. }
  101. //cout << buffer << endl;
  102. buffer = buffer1;
  103. i = 0;
  104. buffer1 = "";
  105. while(buffer[i] != '('){
  106. buffer1 += buffer[i];
  107. i++;
  108. }
  109. i++;
  110. command = buffer1;
  111. buffer1 = "";
  112. while(buffer[i] != ';'){
  113. buffer1 += buffer[i];
  114. i++;
  115. }
  116. i++;
  117. xData = atoi(buffer1.c_str());
  118.  
  119. buffer1 = "";
  120. while(buffer[i] != ')'){
  121. buffer1 += buffer[i];
  122. i++;
  123. }
  124. yData = atoi(buffer1.c_str());
  125. buffer1 = "";
  126. buffer = "";
  127. }
  128. void retRaw(std::string &ret){
  129. ret = raw;
  130. }
  131. std::string retComm(){
  132. return command;
  133. }
  134. void retXdata(int &x){
  135. x = xData;
  136. }
  137. void retYdata(int &y){
  138. y = yData;
  139. }
  140. void retCord(point &ret){
  141. ret.set_x(xData);
  142. ret.set_y(yData);
  143. }
  144. };
  145.  
  146. class doCommands{
  147. private:
  148.  
  149. public:
  150. void process(std::string command, point &dot, point argum){
  151. if(command == "set"){
  152. dot.set_x(argum.ret_x());
  153. dot.set_y(argum.ret_y());
  154. }
  155. }
  156. };
  157.  
  158. int main(int argc, char* argv[])
  159. {
  160. std::string inp;
  161. cin >> inp;
  162. parceCord parcer;
  163. parcer.parceS(inp);
  164. point argum;
  165. parcer.retCord(argum);
  166. argum.ret_cord();
  167. point dot1(0, 0);
  168. doCommands commander;
  169. commander.process(parcer.retComm(), dot1, argum);
  170. dot1.ret_cord();
  171.  
  172. system("pause");
  173. return 0;
  174. }
  175. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement