Загрузка...

Write a program in C++

Thread in C/C++ created by Antitux Dec 14, 2021. 158 views

  1. Antitux
    Antitux Topic starter Dec 14, 2021 0 Aug 26, 2018
    Ввести действительное число x, вычислить и вывести y = 11 * x^10 + 10 * x^9 + 9 * x^8 + ... + 2 * x + 1.

    Разрешены к использованию только следующие функции: printf и scanf.
     
  2. ReverseFlash
    C
    #include <iostream>
    #include <cmath>
    using namespace std;
    int x;
    int fn(int n)
    {
    if (n == 2)
    return n * x + 1;
    return n * pow(x, n - 1) + fn(n - 1);
    }

    int main()
    {
    cin >> x;
    cout << "Y = " << fn(11);
    }
     
  3. kageno
    kageno Dec 14, 2021 1625 Dec 12, 2016
    C
    #include <iostream>

    using namespace std;

    int main()
    {
    int n = 11;
    int res = 0;
    int x;

    scanf("%d", &x);

    int ppow = 1;
    for (int j = 0; j < n - 1; j++) {
    ppow *= x;
    }

    for (int i = n; i > 0; i--) {
    res += i * ppow;

    ppow /= x;
    }

    printf("y = %d", res);
    }
     
Top
Loading...