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

×

this is showing runtime error

#include <stdio.h>
#include<math.h>
int main(void) {
    int n,s,t,i,w[10000],l[10000],k,max;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d\n",s,t);
        if(s>t)
        w[i]=1;
        else 
        w[i]=2;
        l[i]=abs(s-t);
    }max=l[0];
    for(i=0;i<n;i++)
    {
        if(l[i]>max)
        max=l[i];
        k=i;
    }
    printf("%d%d",w[k],max);
    return 0;
}

asked 14 May '15, 21:38

akhil451's gravatar image

2★akhil451
11
accept rate: 0%

edited 14 May '15, 22:59

damn_me's gravatar image

3★damn_me
2.6k21336


because of & not used with s and t and in scanf \n used. use scanf as scanf("%d%d",&s,&t);

link

answered 15 May '15, 00:56

hod23's gravatar image

0★hod23
1
accept rate: 0%

scanf("%d %d\n",s,t);

this line is giving runtime error.

it should be

scanf("%d %d\n",&s,&t);

link

answered 15 May '15, 02:06

sharru05's gravatar image

3★sharru05
5591723
accept rate: 14%

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:

×525
×231
×56

question asked: 14 May '15, 21:38

question was seen: 1,092 times

last updated: 15 May '15, 02:06