Snippets

cia_rana あしあと

Created by cia_rana last modified
#include <stdio.h>
int main(){
    // しょきか
    int pos = 0, dir[5] = {-1, 0, 1, 9, -9};
    char field[99] = "Yxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    
    // あしあとつける
    char c;
    while(scanf(" %c", &c) == 1){
        field[pos+=dir[c % 5]] = 'Y';
    }
    
    // あしあとびょうがする
    size_t i;
    for(i = 0; i < 81; i++){
        printf("%c", field[i]);
        if(i % 9 == 8){
            printf("\n");
        }
    }
    
    // おわり
    return 0;
}
i=0;s=?Y+?x*80;gets.chop.bytes{|c|s[i+=[-1,0,1,9,-9][c%5]]=?Y};puts s.scan /.{9}/

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.