| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
WA十多次了,我的RP真的有问题吗 ?各位看看,frkstyc你也来帮我看看这个代码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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator