You are not logged in. Please login at www.codechef.com to post your questions!

×

Why is my code showing a runtime error?

I have done a codechef excercise named HACKFULU. The code got succesfully executed on my pc but showing a runtime error on Codechef. Please helpmeout

include<stdio.h>

int t; void propseq(int N,int s,int k,int m,int M); void main() { int N,s,k,m,M,l=0; scanf("%d",&t); do { scanf("%d%d%d%d%d",&N,&s,&k,&m,&M); propseq(N,s,k,m,M); l++; }while(l!=t); }

void propseq(int N,int s,int k,int m,int M) { int a[10],b[10],med,med1,i,j,h,z=0; if(m>M&&k==0) { j=-1; goto l1; } for(i=0;i<N;i++) {

if(i==N-1)
{
    if(s<M)
    {
    a[i]=s;
    break;
    }
    else
    {
    j=-1;
    goto l1;
    }
}
if(s>=m)
{
    a[i]=m;
    s=s-m;
}
else
{
    j=-1;
    goto l1;
}

} if(N%2==0) { med=((N/2)+(N/2)-1)/2; } else { med=(N-1)/2; } for(h=0;h<N;h++) { if(h==(N%k)||h==k) { continue; } else { b[h]=a[h]; z++; } } med1=N-2/2; if(a[med]==b[med1]) { j=-1; goto l1; } else {

goto l1;

}

l1: if(j==-1) { printf("%d",j); } else { for(h=0;h<N;h++) { printf("%d\t",a[h]); } }

}

asked 01 Sep '18, 13:10

yesh_allampati's gravatar image

0★yesh_allampati
1
accept rate: 0%


#include<stdio.h>

include<conio.h>

int t; void propseq(int N,int s,int k,int m,int M); void main() { int N,s,k,m,M,l=0; clrscr(); scanf("%d",&t); do { scanf("%d%d%d%d%d",&N,&s,&k,&m,&M); propseq(N,s,k,m,M); l++; }while(l!=t); getch(); }

void propseq(int N,int s,int k,int m,int M) { int a[10],b[10],med,med1,i,j,h,z=0; if(m>M&&k==0) { j=-1; goto l1; } for(i=0;i<N;i++) {

if(i==N-1)
{
    if(s<M)
    {
    a[i]=s;
    break;
    }
    else
    {
    j=-1;
    goto l1;
    }
}
if(s>=m)
{
    a[i]=m;
    s=s-m;
}
else
{
    j=-1;
    goto l1;
}

} if(N%2==0) { med=((N/2)+(N/2)-1)/2; } else { med=(N-1)/2; } for(h=0;h<N;h++) { if(h==(N%k)||h==k) { continue; } else { b[h]=a[h]; z++; } } med1=N-2/2; if(a[med]==b[med1]) { j=-1; goto l1; } else {

goto l1;

}

l1: if(j==-1) { printf("%d",j); } else { for(h=0;h<N;h++) { printf("%d\t",a[h]); } }

}

link

answered 01 Sep '18, 13:11

yesh_allampati's gravatar image

0★yesh_allampati
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×25
×14
×8

question asked: 01 Sep '18, 13:10

question was seen: 83 times

last updated: 01 Sep '18, 13:10