## Perl, 47 bytes

    @a=(1..<>);for(@a){$a=$_;say map{$_==$a?1:0}@a}

Running with the `-E` perlrun:

    $ echo 3 | perl -E'@a=(1..<>);for(@a){$a=$_;say map{$_==$a?1:0}@a}'
    100
    010
    001