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

用%小心0, 用array[k]=小心k<0.

Posted by Lucifer at 2005-09-07 18:14:55 on Problem 1107
In Reply To:为什么会runtime error呀~~~~~求救~~~~~ Posted by:thegoldinsea at 2005-07-25 22:38:55
> #include<stdio.h>
> int scan(int i,int j,int b[],char a[])
> {
>     int k,v=-1;
>     char n=i,m=j;
>     if(i<115)
>     {
>       for(k=0;a[k]!='\0';k++)
>         if(a[k]>=n&&a[k]<=m)
>           b[++v]=k;
>     }
>     else
>     {
>         for(k=0;a[k]!='\0';k++)
>         {   if(a[k]>=n&&a[k]<=m||a[k]=='_')
>                b[++v]=k;
>         }
>     }
>     return v;
> }
> int main()
> {
>     char a[81],d[10],t;
>     int b[10]={0},c[10]={0};
>     int k[4];
>     int i,j,v;
>     scanf("%d%d%d",&k[1],&k[2],&k[3]);
>     while(k[1]!=0&&k[2]!=0&&k[3]!=0)
>     {
>         scanf("%s",a);
>         for(i=1;i<=3;i++)
>         {
>             switch(i)
>             {
>                 case 1:v=scan(97,105,b,a);break;
>                 case 2:v=scan(106,114,b,a);break;
>                 case 3:v=scan(115,122,b,a);break;
>             }
>             if(v>-1)
>             {
>               for(j=0;j<=v;j++)
>               {
>                 c[(j+k[i]+1)%(v+1)]=b[(j+1)%(v+1)];
>                 d[(j+k[i]+1)%(v+1)]=a[c[(j+k[i]+1)%(v+1)]];
>               }
>               for(j=0;j<=v;j++)
>                 a[b[j]]=d[j];
>             }
>         }
>         puts(a);
>         scanf("%d%d%d",&k[1],&k[2],&k[3]);
>     }
>     return 0;
> }

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