fork download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. const int HEART_SIZE = 20;
  5. const int HALF_SIZE = HEART_SIZE / 2;
  6.  
  7. bool is_in_love(int x,int, y);
  8.  
  9. int main(void)
  10. {
  11. std::string message = " SYSTEMATIC LOVE ";
  12. int message_indent = (HALF_SIZE - (message.length() / 4 )) - 1;
  13.  
  14. for(int y = 0; y < HEART_SIZE; ++y)
  15. {
  16. for(int x = 0; x < HEART_SIZE; ++x)
  17. {
  18. std::cout << ((is_in_love(x,y)) ? "vv" : " ");
  19.  
  20. if(Y == HALF_SIZE - 1)
  21. {
  22. if(x == message_indent)
  23. {
  24. std::cout << message.c_str():
  25. x += (message.length() / 2);
  26. }
  27. }
  28.  
  29. }
  30.  
  31. std::cout << "/n" ;
  32. }
  33.  
  34. return 0;
  35. }
  36.  
  37. bool is_in_love(int x,int y)
  38. {
  39. const float width = 2.2f;
  40. const float height = 30.f;
  41. const float HEART_COEFFICIENT = 0.7f
  42.  
  43. float check_x = ((static_cast<float>(x) / static_cast<float>(HEART_SIZE)) - 0.5f) * width;
  44. float check_y = ((static_cast<float>(HEART_SIZE - y) / static_cast<float>(HEART_SIZE)) - 0.4f) * height;
  45.  
  46. float top_y = 0.0f;
  47. float bottom_y = 0.0f;
  48.  
  49. if (check_x >= 0)
  50. {
  51. top_y = sqrt(1 - (check_x * check_x)) + (HEART_COEFFICIENT * sqrt(check_x));
  52. bottom_y = -sqrt(1 - (check_x * check_x)) + (HEART_COEFFICIENT * sqrt(check_x));
  53. }
  54. else
  55. {
  56. top_y = sqrt(1 - (check_x * check_x)) + (HEART_COEFFICIENT * sqrt(-check_x));
  57. bottom_y = -sqrt(1 - (check_x * check_x)) + (HEART_COEFFICIENT * sqrt(-check_x));
  58. }
  59.  
  60. if ((bottom_y <= check_y) && (check_y <= top_y))
  61. {
  62. return true;
  63. }
  64. else
  65. {
  66. return false;
  67. }
  68. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:7:28: error: 'y' has not been declared
 bool is_in_love(int x,int, y);
                            ^
prog.cpp: In function 'int main()':
prog.cpp:18:33: error: too few arguments to function 'bool is_in_love(int, int, int)'
    std::cout << ((is_in_love(x,y)) ? "vv" : " ");
                                 ^
prog.cpp:7:6: note: declared here
 bool is_in_love(int x,int, y);
      ^
prog.cpp:20:7: error: 'Y' was not declared in this scope
    if(Y == HALF_SIZE - 1)
       ^
prog.cpp:24:34: error: expected ';' before ':' token
      std::cout << message.c_str():
                                  ^
prog.cpp: In function 'bool is_in_love(int, int)':
prog.cpp:43:2: error: expected ',' or ';' before 'float'
  float check_x = ((static_cast<float>(x) / static_cast<float>(HEART_SIZE)) - 0.5f) * width;
  ^
prog.cpp:49:9: error: 'check_x' was not declared in this scope
     if (check_x >= 0)
         ^
stdout
Standard output is empty