@tanguatlay,
First sentence is good English, second sentence isn't.
Possible variant of second sentence which is good English:
If I'd won the lottery, I'd have bought a car.
Possible also and also good English:
If I won the lottery, I will buy a car. (speaker doesn't know if he won or not).