Advertisement
Guest User

sdsfafdas

a guest
Feb 26th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5. #include <time.h>
  6.  
  7.  
  8. int randnumber(int a, int b)
  9. {
  10. return rand() % (b - a + 1) + a;
  11. }
  12.  
  13. int genplocha(int a, int b, int c, int d)
  14. {
  15. for (int i = 0; i < b; i = i + 1)
  16. {
  17. printf("\n");
  18. }
  19. for (int i = 0; i < a; i = i + 1)
  20. {
  21. if (i == c)
  22. {
  23. printf("X");
  24. }
  25. else if (i==d)
  26. {
  27. printf("Y");
  28. }
  29. else
  30. {
  31. printf("-");
  32. }
  33. }
  34. printf("\n");
  35. return 0;
  36. }
  37.  
  38. int main()
  39. {
  40. int x, y;
  41. srand(time(0));
  42. x=randnumber(0, 120);
  43. y = randnumber(0, 120);
  44. if (x == y)
  45. {
  46. if (y < 120)
  47. {
  48. y = y + 1;
  49. }
  50. else
  51. {
  52. y = y - 1;
  53. }
  54. }
  55. printf("%d\n", x);
  56. printf("%d\n",y);
  57. genplocha(120, 20, x, y);
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement