Graphs cospectral with a friendship graph or its complement