[ create a new paste ] login | about

Link: http://codepad.org/4IS3H70G    [ raw code | fork ]

C, pasted on Nov 13:
//	Go-Moku SOba
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>

char *exchange( char c, int *val ) {
	static char const alpha[] = "abcdefghijklmnopwrstuvwxyz";
	char *p = strchr( alpha, tolower( c ) );
	if ( p ) *val = p - alpha;
	return p;
}

int main() {
	int *rowp = ( int * )calloc( 1, sizeof( int ) );
	int *columnp = ( int * )calloc( 1, sizeof( int ) );

	while ( 1 ) {
		char buf[2];
		scanf( "%s", buf );
		if ( !isupper( buf[0] ) || !exchange( buf[0], rowp ) ) break;
		if ( !islower( buf[1] ) || !exchange( buf[1], columnp ) ) break;
		printf( "row=%d\ncolumnp=%d\n", *rowp, *columnp );
	}
}


Create a new paste based on this one


Comments: