fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int loca();
  6. int foot();
  7.  
  8. int main()
  9. {
  10. int footprint,gap;
  11. scanf("%d", &footprint);
  12. foot();
  13. scanf("%d", &gap);
  14. loca();
  15. }
  16. int foot()
  17. {
  18. srand(time(NULL));
  19. char map2[10][20] = { '\0' };
  20. int i, j, h, w;
  21. h = rand()%9; w = rand()%17;
  22. map2[h][w] = 'A';
  23. map2[h][w+1] = 'B';
  24. for (i = 0; i < 8; i++) {
  25. for (j = 0; j < 16; j++) {
  26. if (map2[i][j] == '0') printf(" ");
  27. if (map2[i][j] == 'A') printf("A");
  28. if (map2[i][j] == 'B') printf("B");
  29. }
  30. printf("\n");
  31. }
  32. }
  33. int loca()
  34. {
  35. srand(time(NULL));
  36. char map[10][10] = { '\0' };
  37. int i, j, h1, w1, h2=0, w2=0;
  38. h1 = rand() % 9; w1 = rand() % 9;
  39. map[h1][w1] = 'P';
  40. while (h1 < 4) {
  41. if (w1 < 4) {
  42. h2 = rand() % 7 + 4;
  43. w2 = rand() % 7 + 4;
  44. }
  45. else {
  46. h2 = rand() % 7 + 4;
  47. w2 = rand() % 4;
  48. }
  49. }
  50. while(h1>=4) {
  51. if (w1 < 4) {
  52. h2 = rand() % 4;
  53. w2 = rand() % 7 + 4;
  54. }
  55. else {
  56. h2 = rand() % 4;
  57. w2 = rand() % 4;
  58. }
  59. }
  60. map[h2][w2] = 'H';
  61. for (i = 0; i < 8; i++) {
  62. for (j = 0; j < 8; j++) {
  63. if (map[i][j] == '0') printf(" ");
  64. if (map[i][j] == 'P') printf("P");
  65. if (map[i][j] == 'H') printf("H");
  66. }
  67. printf("\n");
  68. }
  69. }
Time limit exceeded #stdin #stdout 5s 4468KB
stdin
100
100
stdout
Standard output is empty