x = # of cans of tomatoes, y = # of cans of corn
x + y = 32.....y = 32 - x
0.80x + 0.40y = 18
0.80x + 0.40(32 - x) = 18
0.80x + 12.8 - 0.40x = 18
0.80x - 0.40x = 18 - 12.8
0.40x = 5.2
x = 5.2 / 0.40
x = 13 <=== 13 cans of tomatoes were bought
leaving (32 - 13) = 19 cans of corn bought