TEMA

runtime error...

gnm preguntado 11 months ago

include

int main () { long long int a=0 ,b ,n,c=0 ,d=0,i,k,j=0,result =0,g=0,p=0; scanf ("%lld",&n); long long int ara[n],ara1[n]; for (i=0;i<n;i++) { scanf ("%lld",&ara[i]); p+=ara[i]; }

for (i=0,j=0;i<n;i++,j++)
{
    if (ara[i]%2 != 0)
    {
        a++;
        ara1[j]=ara[i]-1;
    }
    if (ara[i]!=0 &&ara[i]%2==0)
    {
        a++;
        g++;
        break;
    }
    if (ara[i]==0)
    {
        break;
    }

}
if (g==1)
{
for (j=(a-2);j>=0;j--)
{
    if (ara1[j]!=0)
    {
        c++;
    }
    if (ara[j]==0)
    {
        break;
    }
}
}
k=a+c;

result = p -k;
printf ("%lld %lld\n",a,result);
return 0;

}

Recuerda no enviar soluciones. Tu mensaje puede ser revisado por nuestros moderadores.

  • gnm respondido 11 months ago

    i am in too much problem in the code .......i have performed maximum of udebug .....output is right ....but runtime error......why???

  • feodorv respondido 11 months ago

    Can you try to add return 0; in the end of main() function?