Skip to content

Instantly share code, notes, and snippets.

@dd1994
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save dd1994/73fcb0cc4ff60b83aaa6 to your computer and use it in GitHub Desktop.

Select an option

Save dd1994/73fcb0cc4ff60b83aaa6 to your computer and use it in GitHub Desktop.
#include <iostream>
#define MAX 100
using namespace std;
int main(void)
{
int i, j, m, n;
double a[MAX];
cout << "please input n: ";
cin >> n;
cout << "please input a[n], a[n-1]...,a[1],a[0](one space between them):" << endl;
for (i = n; i >= 0; --i)
{
cin >> a[i];
}
cout << "please input m(m <= n):";
cin >> m;
for (i = n; i > m - 1; --i)
{
for (j = i; j > i - m; --j)
{
a[i] *= j;
}
}
cout << "The answer:" << endl;
for (i = n; i > m; --i)
{
cout << a[i] << 'x' << '^' << i - m << '+';
}
cout << a[m] << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment