| ||||||||||
| 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 | |||||||||
诡异的现象,求大牛解释C++编译器下:以下代码提交AC,但是将数组dp改为dp1或pRes等其他变量名后都WA。
#include<cstdio>
#include<cstring>
const int SIZE=5000;
char pStr[SIZE];
int dp[SIZE];
int main()
{
while(scanf("%s",pStr)!=EOF)
{
if(pStr[0]=='0')
break;
getchar();
memset(dp,0,sizeof(dp));
dp[0]=1;
dp[1]=1;
int i;
for(i=1;pStr[i]!='\0';i++)
{
if(pStr[i]=='0')
{
dp[i+1]=dp[i-1];
continue;
}
if(pStr[i-1]=='0')
{
dp[i+1]=dp[i];
continue;
}
int t=(pStr[i-1]-'0')*10+pStr[i]-'0';
if(t<=26)
{
dp[i+1]=dp[i]+dp[i-1];
}else
{
dp[i+1]=dp[i];
}
}
printf("%d\n",dp[i]);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator