#include<iostream> #include<iomanip> using namespace std;
int **create(int n, int m) { int k = 0; int **arr = new int*[n]; for (int i = 0; i < n; i++) { arr[i] = new int[m]; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (arr[i][0]) { arr[i][0] = i; } if (arr[i][1]) { arr[i][1] = i * i; } if(arr[i][2]) { arr[i][2] = pow(i, 3); } } } return arr; } void print(int **arr, int n, int m) { for (int i = 1; i < n; i++) { for (int j = 0; j < m; j++) { cout << setw(5) << arr[i][j] << "\t"; } cout << endl; } } int main() { setlocale(LC_ALL, "ru"); int n, m = 3; cout << "Введите число n = "; cin >> n; int**arr = create(n,m); cout << endl; print(arr, n, m); cout << endl; system("PAUSE"); return 0; }
using namespace std;
int main()
{
int n;
cin >> n;
for (int i=1; i<=n; i++) {
cout << i << " " << i*i << " " << i*i*i << "\n";
}
return 0;
}
Пример:
5
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
#include<iomanip>
using namespace std;
int **create(int n, int m)
{
int k = 0; int **arr = new int*[n];
for (int i = 0; i < n; i++)
{ arr[i] = new int[m];
} for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (arr[i][0])
{
arr[i][0] = i;
}
if (arr[i][1])
{
arr[i][1] = i * i;
}
if(arr[i][2])
{
arr[i][2] = pow(i, 3);
}
}
} return arr;
}
void print(int **arr, int n, int m)
{
for (int i = 1; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cout << setw(5) << arr[i][j] << "\t"; } cout << endl;
}
}
int main()
{
setlocale(LC_ALL, "ru");
int n, m = 3;
cout << "Введите число n = "; cin >> n;
int**arr = create(n,m);
cout << endl;
print(arr, n, m);
cout << endl;
system("PAUSE");
return 0;
}