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

×

why am i getting wrong answer,yet it is right on my local machine??(the Smallest pair ,problem)

include<stdio.h>

include<stdlib.h>

int comp(const void ,const void );

int main(){ int i=0,t=0,n=0,j=0; long int arr[100]; // printf("enter the noo of test cases"); scanf("%d",&t); for(i=0;i<t;i++){ printf("enter="" the="" value="" of="" n");="" scanf("%d",&n);="" if(n="">=2){ //printf("enter the sequence"); for(j=0;j<n;j++){ scanf("%ld",&arr[j]); }

     qsort(arr,n,sizeof(int),comp);
     printf("%ld",(arr[0]+arr[1]));

     }
     }

return 0; }

int comp(const void i,const void j){ return (int )i- (int )j ; }

asked 29 Jun '14, 22:24

va1ts7_10's gravatar image

1★va1ts7_10
13
accept rate: 0%


Your program is not printing new line . Also size of array is less . Here is your corrected code

link

answered 29 Jun '14, 22:45

the65bit's gravatar image

4★the65bit
1.1k101328
accept rate: 13%

edited 29 Jun '14, 22:47

your output should match with the output pattern specified. Like you're printing "Enter the noo of test cases". This will not match the output file pattern on codechef.

link

answered 30 Jun '14, 09:16

blackcat013's gravatar image

2★blackcat013
1
accept rate: 0%

These lines are commented in the code .

(30 Jun '14, 10:25) the65bit4★
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:

×131
×12
×8

question asked: 29 Jun '14, 22:24

question was seen: 883 times

last updated: 30 Jun '14, 10:25