1. C++, Evgeni Pavlidis


/**
* ACM programming Contest WS 08/09
* UVa Status: accepted
* Run Time: 1.220
* Category: -
* @author Evgeni Pavlidis evgenipavlidis@yahoo.de
*/
#include <iostream>

using namespace std;

#define MAX 9

int p[MAX];

int main()
{
while(true)
{
for(int i=MAX-1; i >= 0; i--)
cin >> p[i];

if(feof(stdin))
return 0;

string result;

int start = MAX-1;
while(p[start] == 0 && start >= 0)
start--;

if(start >= 0)
cout << ((p[start] > 0)? "":"-");

if(abs(p[start]) != 1 || start == 0)
cout << abs(p[start]);

if(start > 0)
cout << "x";
if(start > 1)
cout << "^" << start;

for(int i=start-1; i >= 0; i--)
if(p[i] != 0)
{
cout << " " << ((p[i] > 0)? "+":"-") << " ";
if(abs(p[i]) != 1 || i == 0)
cout << abs(p[i]);

if(i > 0)
cout << "x";
if(i > 1)
cout << "^" << i;
}

cout << endl;
}
}