#include <iostream>
using namespace std;
int main()
{
int i;
for (i=1000; i<=9999; i++)
if (i%5==0 && ((i/1000)+(i/100%10)==12)) cout << i << " ";
return 0;
}
sau mai eficient:
#include <iostream>
using namespace std;
int main()
{
int a, b, c, d;
for (a=1; a<=9; a++)
for (b=0; b<=9; b++)
for (c=0; c<=9; c++)
for (d=0; d<=9; d++)
if (a+b==12) if (d==0 || d==5) cout << a*1000+b*100+c*10+d << " ";
return 0;
}