Let x be the efficiency for the first car and let y be the efficiency for the second car.
We know that the firt car consumed 35 gallons, the second 25 gallons and that they drove a combined total of 1025 miles, then we have the equation:

We also know that the sum of their efficiencies was 35, then we have:

Hence we have the system of equations:

To find the solution of the system let's solve the second equation for y:

Plugging this in the first equation we have:

Now that we have the value of x we plug it in the expression for y:

Therefore the efficiency of the first car was 15 miles per gallon and the efficiency of the second car was 20 miles per gallon