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

×

Solution to CHEFSUM.It is showing W.A.Why?

#include<stdio.h>
int main()
{
int T,i;
scanf("%d",&T);
while(T!=0)
{
int n;
scanf("%d",&n);
int A[n];
for(i=0;i<n;i++)
scanf("%d",&A[i]);
int k=A[0];
int j=0;
for(i=0;i<n;i++)
{
if(A[i]<k)
{
k=A[i];
j=i;
}
}
printf("%d",j+1);
T--;
}
return 0;
}

asked 02 Oct '17, 00:22

utchinu's gravatar image

3★utchinu
01
accept rate: 0%

edited 02 Oct '17, 00:24

vijju123's gravatar image

5★vijju123 ♦♦
15.4k12066


printf("%d",j+1);

Print each answer on a new line. Use newline character.

link

answered 02 Oct '17, 00:27

vijju123's gravatar image

5★vijju123 ♦♦
15.4k12066
accept rate: 18%

2

Adding to it

printf("%d\n",j+1); <---like this

(02 Oct '17, 00:33) trashmaster2★
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:

×155
×70
×20

question asked: 02 Oct '17, 00:22

question was seen: 241 times

last updated: 02 Oct '17, 00:33