#16400: 求教學

#### asddzxcc1856 (嚕踢)

School : 國立中興大學
ID : 86097
IP address : [61.223.99.184]
2023-08-21 21:25:52
c060. 00392 - Polynomial Showdown -- | From: [111.252.73.184] | Post Date : 2018-12-29 15:06

#include<cstdio>
using namespace std;

int main ()
{
while (1)
{
int a[9],x=0;
scanf("%d%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8]);
for (int i=0;i<9;i++)
{
x=10-i-2;
if (a[i]!=0 && a[i]!=1 && a[i]!=-1)
{
printf("%dx^%d",a[i],x);
a[i]=0;
break;
}
else if (a[i]==1)
{
printf("x^%d",x);
a[i]=0;
break;
}
else if (a[i]==-1)
{
printf("-x^%d",x);
a[i]=0;
break;
}
}
for (int i=10-x-1;i<9;i++)
{
x-=1;
if (x==0 && a[i]>0)
printf(" + %d",a[i]);
else if (x==0 && a[i]<0)
printf(" - %d",-a[i]);
else if (x==1 && a[i]==1)
printf(" + x");
else if (x==1 && a[i]==-1)
printf(" - x");
else if (x==1 && a[i]<0)
printf(" - %dx",-a[i]);
else if (x==1 && a[i]>0)
printf(" + %dx",a[i]);
else if (a[i]>0 && a[i]!=1 && x!=1)
printf(" + %dx^%d",a[i],x);
else if (a[i]==1 && x!=1)
printf(" + x^%d",x);
else if (a[i]<0 &&a[i]!=-1 && x!=1)
printf(" - %dx^%d",-a[i],x);
else if (a[i]==-1 && x!=1)
printf(" - x^%d",x);
}
printf("\n");
}
}

#16401: Re:求教學

#### 314159265358979323846264338327 ... (少年π)

School : 臺北市私立延平高級中學
ID : 69058
IP address : [223.136.179.30]
2024-04-29 19:11:35
c060. 00392 - Polynomial Showdown -- | From: [223.137.73.62] | Post Date : 2018-12-29 16:20

#include
using namespace std;

int main ()
{
while (1)
{
int a[9],x=0;
scanf("%d%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8]);
for (int i=0;i<9;i++)
{
x=10-i-2;
if (a[i]!=0 && a[i]!=1 && a[i]!=-1)
{
printf("%dx^%d",a[i],x);
a[i]=0;
break;
}
else if (a[i]==1)
{
printf("x^%d",x);
a[i]=0;
break;
}
else if (a[i]==-1)
{
printf("-x^%d",x);
a[i]=0;
break;
}
}
for (int i=10-x-1;i<9;i++)
{
x-=1;
if (x==0 && a[i]>0)
printf(" + %d",a[i]);
else if (x==0 && a[i]<0)
printf(" - %d",-a[i]);
else if (x==1 && a[i]==1)
printf(" + x");
else if (x==1 && a[i]==-1)
printf(" - x");
else if (x==1 && a[i]<0)
printf(" - %dx",-a[i]);
else if (x==1 && a[i]>0)
printf(" + %dx",a[i]);
else if (a[i]>0 && a[i]!=1 && x!=1)
printf(" + %dx^%d",a[i],x);
else if (a[i]==1 && x!=1)
printf(" + x^%d",x);
else if (a[i] printf(" - %dx^%d",-a[i],x);
else if (a[i]==-1 && x!=1)
printf(" - x^%d",x);
}
printf("\n");
}
}

while(1)是無窮迴圈

#16411: Re:求教學

#### asddzxcc1856 (嚕踢)

School : 國立中興大學
ID : 86097
IP address : [61.223.99.184]
2023-08-21 21:25:52
c060. 00392 - Polynomial Showdown -- | From: [111.252.73.184] | Post Date : 2018-12-29 19:24

#include
using namespace std;

int main ()
{
while (1)
{
int a[9],x=0;
scanf("%d%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8]);
for (int i=0;i<9;i++)
{
x=10-i-2;
if (a[i]!=0 && a[i]!=1 && a[i]!=-1)
{
printf("%dx^%d",a[i],x);
a[i]=0;
break;
}
else if (a[i]==1)
{
printf("x^%d",x);
a[i]=0;
break;
}
else if (a[i]==-1)
{
printf("-x^%d",x);
a[i]=0;
break;
}
}
for (int i=10-x-1;i<9;i++)
{
x-=1;
if (x==0 && a[i]>0)
printf(" + %d",a[i]);
else if (x==0 && a[i]<0)
printf(" - %d",-a[i]);
else if (x==1 && a[i]==1)
printf(" + x");
else if (x==1 && a[i]==-1)
printf(" - x");
else if (x==1 && a[i]<0)
printf(" - %dx",-a[i]);
else if (x==1 && a[i]>0)
printf(" + %dx",a[i]);
else if (a[i]>0 && a[i]!=1 && x!=1)
printf(" + %dx^%d",a[i],x);
else if (a[i]==1 && x!=1)
printf(" + x^%d",x);
else if (a[i] printf(" - %dx^%d",-a[i],x);
else if (a[i]==-1 && x!=1)
printf(" - x^%d",x);
}
printf("\n");
}
}

while(1)是無窮迴圈

#include<cstdio>

int main ()

{

int a[9];

while (scanf("%d%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8])!=EOF)

{

int x=0;

for (int i=0;i<9;i++)

{

x=10-i-2;

if (x==0 && a[i]>0)

{

printf("%d",a[i]);

a[i]=0;

break;

}

else if (x==0 && a[i]<0)

{

printf("%d",a[i]);

a[i]=0;

break;

}

else if (x==1 && a[i]==1)

{

printf("x");

a[i]=0;

break;

}

else if (x==1 && a[i]==-1)

{

printf("-x");

a[i]=0;

break;

}

else if (a[i]!=0 && a[i]!=1 && a[i]!=-1)

{

printf("%dx^%d",a[i],x);

a[i]=0;

break;

}

else if (a[i]==1)

{

printf("x^%d",x);

a[i]=0;

break;

}

else if (a[i]==-1)

{

printf("-x^%d",x);

a[i]=0;

break;

}

else if (a[i]==0 && x==0)

{

printf("%d",a[i]);

break;

}

}

for (int i=10-x-1;i<9;i++)

{

x-=1;

if (x==0 && a[i]>0)

printf(" + %d",a[i]);

else if (x==0 && a[i]<0)

printf(" - %d",-a[i]);

else if (x==1 && a[i]==1)

printf(" + x");

else if (x==1 && a[i]==-1)

printf(" - x");

else if (x==1 && a[i]<0)

printf(" - %dx",-a[i]);

else if (x==1 && a[i]>0)

printf(" + %dx",a[i]);

else if (a[i]>0 && a[i]!=1 && x!=1)

printf(" + %dx^%d",a[i],x);

else if (a[i]==1 && x!=1)

printf(" + x^%d",x);

else if (a[i]<0 &&a[i]!=-1 && x!=1)

printf(" - %dx^%d",-a[i],x);

else if (a[i]==-1 && x!=1)

printf(" - x^%d",x);

}

printf("\n");

}

}

#16412: Re:求教學

#### asddzxcc1856 (嚕踢)

School : 國立中興大學
ID : 86097
IP address : [61.223.99.184]
2023-08-21 21:25:52
c060. 00392 - Polynomial Showdown -- | From: [111.252.73.184] | Post Date : 2018-12-29 19:25

#include
using namespace std;

int main ()
{
while (1)
{
int a[9],x=0;
scanf("%d%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8]);
for (int i=0;i<9;i++)
{
x=10-i-2;
if (a[i]!=0 && a[i]!=1 && a[i]!=-1)
{
printf("%dx^%d",a[i],x);
a[i]=0;
break;
}
else if (a[i]==1)
{
printf("x^%d",x);
a[i]=0;
break;
}
else if (a[i]==-1)
{
printf("-x^%d",x);
a[i]=0;
break;
}
}
for (int i=10-x-1;i<9;i++)
{
x-=1;
if (x==0 && a[i]>0)
printf(" + %d",a[i]);
else if (x==0 && a[i]<0)
printf(" - %d",-a[i]);
else if (x==1 && a[i]==1)
printf(" + x");
else if (x==1 && a[i]==-1)
printf(" - x");
else if (x==1 && a[i]<0)
printf(" - %dx",-a[i]);
else if (x==1 && a[i]>0)
printf(" + %dx",a[i]);
else if (a[i]>0 && a[i]!=1 && x!=1)
printf(" + %dx^%d",a[i],x);
else if (a[i]==1 && x!=1)
printf(" + x^%d",x);
else if (a[i] printf(" - %dx^%d",-a[i],x);
else if (a[i]==-1 && x!=1)
printf(" - x^%d",x);
}
printf("\n");
}
}

while(1)是無窮迴圈

#include

int main ()

{

int a[9];

while (scanf("%d%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8])!=EOF)

{

int x=0;

for (int i=0;i<9;i++)

{

x=10-i-2;

if (x==0 && a[i]>0)

{

printf("%d",a[i]);

a[i]=0;

break;

}

else if (x==0 && a[i]<0)

{

printf("%d",a[i]);

a[i]=0;

break;

}

else if (x==1 && a[i]==1)

{

printf("x");

a[i]=0;

break;

}

else if (x==1 && a[i]==-1)

{

printf("-x");

a[i]=0;

break;

}

else if (a[i]!=0 && a[i]!=1 && a[i]!=-1)

{

printf("%dx^%d",a[i],x);

a[i]=0;

break;

}

else if (a[i]==1)

{

printf("x^%d",x);

a[i]=0;

break;

}

else if (a[i]==-1)

{

printf("-x^%d",x);

a[i]=0;

break;

}

else if (a[i]==0 && x==0)

{

printf("%d",a[i]);

break;

}

}

for (int i=10-x-1;i<9;i++)

{

x-=1;

if (x==0 && a[i]>0)

printf(" + %d",a[i]);

else if (x==0 && a[i]<0)

printf(" - %d",-a[i]);

else if (x==1 && a[i]==1)

printf(" + x");

else if (x==1 && a[i]==-1)

printf(" - x");

else if (x==1 && a[i]<0)

printf(" - %dx",-a[i]);

else if (x==1 && a[i]>0)

printf(" + %dx",a[i]);

else if (a[i]>0 && a[i]!=1 && x!=1)

printf(" + %dx^%d",a[i],x);

else if (a[i]==1 && x!=1)

printf(" + x^%d",x);

else if (a[i]

printf(" - %dx^%d",-a[i],x);

else if (a[i]==-1 && x!=1)

printf(" - x^%d",x);

}

printf("\n");

}

}

ZeroJudge Forum