题解
2023-01-01 16:20:44
发布于:广东
162阅读
0回复
0点赞
代码见下:
#include<stdio.h>
#include<malloc.h>
FILE *o;
FILE *i;
int main(){
unsigned long long n,i1,*s;
scanf("%llu",&n);
// s=(long long*)malloc(n*sizeof(s[0]));
long long x=0,out=1;
for(i1=n;i1>1&&out;i1--){
scanf("%lld",&x);
if(x==0)continue;
if(x==1){
printf("x^%lld",i1);
}else if(x==-1){
printf("-x^%lld",i1);
}else printf("%lldx^%lld",x,i1);
out=0;
}
for(;i1>1;i1--){
scanf("%lld",&x);
if(x==0)continue;
if(x>0)printf("+");
if(x==-1){
printf("-x^%lld",i1);
continue;
}
if(x==1){
printf("x^%lld",i1);
continue;
}
printf("%lldx^%llu",x,i1);
}
if(i1==1){
scanf("%lld",&x);
if(x){
if(x>0)printf("+");
if(x==1)printf("x");
else if(x==-1)printf("-x");
else printf("%lldx",x);
}
i1--;
}
if(i1==0){
scanf("%lld",&x);
if(x){
if(x>0)printf("+");
printf("%lld",x);
}
}
if(out)printf("0");
return 0;
}
这里空空如也
有帮助,赞一个