// p04_03.cpp: Display all positive integers x less than 100,
// such that a given digit d occurs in both x and in x*x
#include <iostream>
#include <iomanip>
using namespace std;
bool occursIn(int d, int x) { // ?? Does digit d in integer x?
 while (x != 0) {
  if (d == x % 10)
   return true;
  x /= 10;
 }
 return false;
}

int main() {
 int d, x;
 cout << "Enter a decimal digit (0 - 9): ";
 cin >> d;
 for (x = 1; x < 10000; ++x) {
  if (occursIn(d,x) && occursIn(d,x*x)) {
   cout << setw(2) << x << setw(6) << x*x << endl;
  }
 return 0;
}
