2020-11-10 03:02:11 +03:00
|
|
|
/* Header: sm.c,v 7.0 86/10/08 15:13:35 lwall Exp */
|
2020-11-10 02:37:05 +03:00
|
|
|
|
2020-11-10 03:02:11 +03:00
|
|
|
/* Log: sm.c,v
|
2020-11-10 02:37:05 +03:00
|
|
|
* Revision 7.0 86/10/08 15:13:35 lwall
|
|
|
|
* Split into separate files. Added amoebas and pirates.
|
2021-05-02 15:50:43 +03:00
|
|
|
*
|
2020-11-10 02:37:05 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
2020-11-10 11:49:08 +03:00
|
|
|
#include <stdlib.h>
|
2020-11-10 02:37:05 +03:00
|
|
|
#include "config.h"
|
|
|
|
|
2020-11-10 11:49:08 +03:00
|
|
|
int
|
2020-11-11 01:42:19 +03:00
|
|
|
main(void)
|
2020-11-10 02:37:05 +03:00
|
|
|
{
|
|
|
|
char screen[23][90], buf[10];
|
2020-11-11 01:42:19 +03:00
|
|
|
int y;
|
|
|
|
int x;
|
2020-11-10 02:37:05 +03:00
|
|
|
int tmpy, tmpx;
|
|
|
|
|
|
|
|
for (x=0; x<79; x++)
|
|
|
|
screen[0][x] = ' ';
|
|
|
|
screen[0][79] = '\0';
|
2021-05-02 15:50:43 +03:00
|
|
|
|
2020-11-10 02:37:05 +03:00
|
|
|
fgets(screen[0],90,stdin);
|
|
|
|
if (isdigit(screen[0][0])) {
|
|
|
|
int numstars = atoi(screen[0]);
|
|
|
|
|
|
|
|
for (y=0; y<23; y++) {
|
|
|
|
for (x=0; x<79; x++)
|
|
|
|
screen[y][x] = ' ';
|
|
|
|
screen[y][79] = '\0';
|
|
|
|
}
|
2021-05-02 15:50:43 +03:00
|
|
|
|
2020-11-10 02:37:05 +03:00
|
|
|
for ( ; numstars; numstars--) {
|
|
|
|
scanf("%d %d\n",&tmpy,&tmpx);
|
|
|
|
y = tmpy;
|
|
|
|
x = tmpx;
|
|
|
|
screen[y][x+x] = '*';
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y=0; y<23; y++) {
|
|
|
|
printf("%s\n",screen[y]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2020-11-11 01:42:19 +03:00
|
|
|
int numstars = 0;
|
2020-11-10 02:37:05 +03:00
|
|
|
|
|
|
|
for (y=1; y<23; y++) {
|
|
|
|
for (x=0; x<79; x++)
|
|
|
|
screen[y][x] = ' ';
|
|
|
|
screen[y][79] = '\0';
|
|
|
|
}
|
2021-05-02 15:50:43 +03:00
|
|
|
|
2020-11-10 02:37:05 +03:00
|
|
|
for (y=1; y<23; y++) {
|
|
|
|
fgets(screen[y],90,stdin);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y=0; y<23; y++) {
|
|
|
|
for (x=0; x<80; x += 2) {
|
|
|
|
if (screen[y][x] == '*') {
|
|
|
|
numstars++;
|
|
|
|
}
|
|
|
|
else if (screen[y][x] == '\t' || screen[y][x+1] == '\t') {
|
|
|
|
fprintf(stderr,"Cannot have tabs in starmap--please expand.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%d\n",numstars);
|
|
|
|
|
|
|
|
for (y=0; y<23; y++) {
|
|
|
|
for (x=0; x<80; x += 2) {
|
|
|
|
if (screen[y][x] == '*') {
|
|
|
|
printf("%d %d\n",y,x/2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|