G

Untitled

public
Guest Mar 23, 2025 Never 13
Clone
Plaintext paste1.txt 27 lines (27 loc) | 589 Bytes
1
{
2
n = NF; output = ""; first = 1;
3
for(i = 1; i <= NF; i++){
4
coef = $i; exp = n - i + 1;
5
if(coef == 0) continue; # pomijamy zero
6
term = "";
7
if(first == 0){
8
if(coef > 0)
9
term = term "+";
10
else
11
term = term "-";
12
} else {
13
if(coef < 0)
14
term = term "-";
15
}
16
if(coef < 0)
17
coef = -coef;
18
term = term coef;
19
if(exp > 1) # pomijamy x^1
20
term = term "x^" exp;
21
output = output term;
22
first = 0;
23
}
24
if(output == "")
25
output = "0";
26
print output;
27
}