| ||||||||||
| 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 | |||||||||
为什么总是Runtime Error??????????????????为什么在VC上能运行,测试结果也是正确的,submit后总是Runtime Error!
帮忙看一下吧。
#include<stdio.h>
int F(int a,int b);
int main(void)
{
int a[20];
char b[6];
int j;
int i=0;
while(scanf("%s",b))
{
a[i]=atoi(b);
i++;
}
for(j=0;j<i;j=j+2)
{
printf("%d %d %d\n",a[j],a[j+1],F(a[j],a[j+1]));
}
return 0;
}
int F(int a,int b)
{
int s;
int max=0;
int t;
for(a=a;a<=b;a++)
{
t=a;
s=1;
while(t!=1)
{
if(t%2==1)
{
t=3*t+1;
}
else
{
t=t/2;
}
s++;
}
if(s>max)
{max=s;}
}
return max ;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator