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

难道就错在我申请了个全局变量 ? 在线,等答案

Posted by nuciedh at 2008-04-10 10:50:52 on Problem 3550 and last updated at 2008-04-10 10:56:09
In Reply To:WA十多次了,我的RP真的有问题吗 ?各位看看,frkstyc你也来帮我看看 Posted by:nuciedh at 2008-04-10 10:44:01
> 这个代码WA了  原因是len是全局变量 ?
> #include <stdio.h>
> #include <string.h>
> 
> char a[510], len;
> 
> void solve ()
> {
>      int i, j;
>      len = strlen(a);
>      for (i = 2, j = 2; i < len; )
>      {
>          if(a[i]=='&'||a[i]=='#'||a[i]=='@') i += 2;
>          else while (a[i] >= 'A' && a[i] <= 'Z') i ++;
>          
>          while (a[i]>= '0' && a[i] <= '9') i ++;
>          if (a[i] == '=')
>          {
>                   i ++;
>                   while (a[i]>= '0' && a[i] <= '9') i ++;
>          }
>          while (j < i) printf ("%c", a[j ++]);
>          printf ("\n");
>      }
> }
> 
> int main()
> {
>     
>     scanf("%s", a);
>     solve ();
>     return 0;
> }
> 下面的AC了:
> #include <stdio.h>
> #include <string.h>
> 
> char a[510];
> 
> void solve ()
> {
>      int i, j, len;
>      len = strlen(a);
>      for (i = 2, j = 2; i < len; )
>      {
>          if(a[i]=='&'||a[i]=='#'||a[i]=='@') i += 2;
>          else while (a[i] >= 'A' && a[i] <= 'Z') i ++;
>          
>          while (a[i]>= '0' && a[i] <= '9') i ++;
>          if (a[i] == '=')
>          {
>                   i ++;
>                   while (a[i]>= '0' && a[i] <= '9') i ++;
>          }
>          while (j < i) printf ("%c", a[j ++]);
>          printf ("\n");
>      }
> }
> 
> int main()
> {
>     
>     scanf("%s", a);
>     solve ();
>     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