home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / lib / r_la4_01 / plot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-11-23  |  861 b   |  33 lines

  1. /* plot.c */
  2. /* plots coordinates on screen */
  3. #define HEIGHT 5
  4. #define WIDTH 10
  5.  
  6. main()
  7. {
  8. char matrix[HEIGHT][WIDTH];
  9. int x, y;
  10.  
  11.    for(y = 0; y < HEIGHT; y++)      /* fill matrix with periods */
  12.       for(x = 0; x < WIDTH; x++)
  13.          matrix[y][x] = '.';
  14.    printf("Enter coordinates in form x,y (4,2).\n");
  15.    printf("Use negative numbers to quit.\n");
  16.  
  17.    while(x >= 0)  {        /* until neg coordinates */
  18.       for(y = 0; y < HEIGHT; y++) {    /*print matrix*/
  19.          for(x = 0; x < WIDTH; x++)
  20.             printf("%c ", matrix[y][x]);
  21.          printf("\n\n");
  22.       }
  23.       printf("Coordinates: ");
  24.       scanf("%d,%d", &x, &y);    /* get coordinates */
  25.       if (x > 9 || y > 4) {
  26.          printf("\n\nLimits: x = 9, y = 4");
  27.          break;
  28.       }
  29.       matrix[y][x] = '\xb0';     /* put gray box there */
  30.    }
  31. }
  32.  
  33.