fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. #define WIDTH 80
  4. #define HEIGHT 40
  5. using namespace std;
  6.  
  7. //just including basic stuff please try to make solution without including more lib.
  8.  
  9. int grid[HEIGHT][WIDTH];
  10. int x, y, xp, xs, yp, ys, n;
  11. int length=HEIGHT * WIDTH;
  12.  
  13. void printarray () {
  14. //it will print array when it is called in to the console
  15. for (y=0; y<HEIGHT; y++) {
  16. for (x=0; x<WIDTH; x++) {
  17. /*if (grid[y][x]%2 == 0){ //just test
  18.   printf("#");
  19.   }else{
  20.   printf("_");
  21.   }
  22.   }
  23.   printf("\n");
  24.   }
  25.  
  26.   for (int n=0; n<WIDTH; ++n){
  27.   printf("=");
  28.   }
  29.   printf("\n");
  30. }*/
  31. if (grid[y][x]==1) {
  32. //it just dicide if it draw # or _
  33. printf("#");
  34. }
  35. else {
  36. printf("_");
  37. }
  38. }
  39. printf("\n");
  40. }
  41. for (int n=0; n<WIDTH; ++n) {
  42. printf("=");
  43. }
  44. printf("\n");
  45. }
  46.  
  47. void rect (int xp, int yp, int xs, int ys) {
  48. //it should print rectangle
  49. for (y=yp; y<=yp+ys; y++) {
  50. //xp is position on x
  51. grid[y][xp]=1; //xs is how long is on x
  52. grid[y][xp+xs]=1; //every loop set 2 lines in array grid[][]
  53. }
  54. for (x=xp; x<=xp+xs; x++) {
  55. grid[yp][x]=1;
  56. grid[yp+ys][x]=1;
  57. }
  58. }
  59.  
  60. int main() { //main function
  61. for (y=0; y<HEIGHT; y++)
  62. for (x=0; x<WIDTH; x++) {
  63. //grid[y][x] = x+y*(WIDTH-1); //just part of test
  64. grid[y][x]=0;
  65. } //and it sometimes write in my build log Process terminated with status -1073741510
  66. rect(2, 2, 3, 5); //if i call this function my console crash or dont do anything
  67. printarray();
  68. return 0;
  69. }
Success #stdin #stdout 0s 4496KB
stdin
Standard input is empty
stdout
________________________________________________________________________________
________________________________________________________________________________
__####__________________________________________________________________________
__#__#__________________________________________________________________________
__#__#__________________________________________________________________________
__#__#__________________________________________________________________________
__#__#__________________________________________________________________________
__####__________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
================================================================================