1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <iostream>
using namespace std;
int main()
{
int squares[10][2] = {
{1,1},
{2,4},
{3,9},
{4,16},
{5,25},
{6,36},
{7,49},
{8,64},
{9,81},
{10,100}
};
int choice,i;
cout << "Enter a number for its square: ";
cin >> choice;
for (i=0;i<10;++i) if (squares[i][0] == choice) break;
cout << "\nThe square of " << squares[i][0] << " is " << squares[i][1];
cout << "\n";
return 0;
}
|