Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

如果只有一个1 或 -1 你这个程序好像不会输出1 或 -1

Posted by K208 at 2005-10-04 11:10:11 on Problem 1555
In Reply To:Re:这样到底有什么问题,还是请指教一下 Posted by:glaver at 2004-03-01 20:33:57
> #include "stdio.h"
> int init(int y[])
> {
>     int num;
>     int i;
>     if(scanf("%d",&num)==EOF) return 0;
>     y[8]=num;
>     for( i=7;i>=0;i--)
>         scanf("%d",&y[i]);
>     return 1;
> }
> 
> main()
> {
>    char x[9][4]={"","x","x^2","x^3","x^4","x^5","x^6","x^7","x^8"};
>    int i,y[9];
> 
>    while(init(y))
>      {
>       i=9;
>       while(y[--i]==0);
>          if(y[i]!=1&&y[i]!=-1)
>               printf("%d%s",y[i],x[i]);
>          else
>               if(y[i]==1) printf("%s",x[i]);
>               else       printf("-%s",x[i]);
>       while(--i)
>         {
>          if(y[i]==0) continue;
>          if(y[i]!=1&&y[i]!=-1)
>               if(y[i]>0) printf(" + %d%s",y[i],x[i]);
>               else       printf(" - %d%s",-y[i],x[i]);
>          else
>               if(y[i]==1) printf(" + %s",x[i]);
>               else       printf(" - %s",x[i]);
>         }
>          if(y[i]>0)           printf(" + %d",y[i]);
>          else if(y[i]<0)      printf(" - %d",-y[i]);
>       printf("\n");
>      }
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator