Search This Blog

Sunday, February 26, 2017

Getting started with Code chef, how to submit your first code ?

 

I have been trying code chef for a while but whenever I used to submit my code, it used to give me some non zero exit code error and I couldn’t find out the reason for this.

so here is a solution to the non zero exit code problem.

 

Try this

https://www.codechef.com/problems/TEST

///////////


import java.util.Scanner;
public class Main {
public static void main(String args[]) {
  int inputNumber;
  Scanner scanner = new Scanner(System.in);
  while (true) {
   inputNumber = scanner.nextInt();
   if (inputNumber != 42) System.out.println(inputNumber);
   else System.exit(0);
  }
}
}

///////////////////

 

If you submit this, your compile will pass.

No comments:

Post a Comment