Either contact the professor and see if you can talk it out, do some sort of an appeal, or just accept that you shouldn't have put yourself in a position where you were on the fringe of failing anyway. Keep in mind, it's not his fault you failed. Be tactful if you try to talk to him or file an appeal.