Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long long factorial(int n){
- long long res = 1;
- int i = 1;
- while (i <= n){
- res *= i;
- i++;
- }
- return res;
- }
- void fill(int a[],int n){
- for (int i = 0; i < n+1; i++) {
- a[i] = factorial(i);
- }
- }
- int main()
- {
- int n;
- cout << "Введите количество элементов массива : ";
- cin >> n;
- int * a = new int[n+1];
- fill(a, n);
- for (int i = 0; i < n + 1; i++){
- cout << a[i] << " ";
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement