UNONE june lunchtime

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(reader.readLine());
while(T!=0){
int N = Integer.parseInt(reader.readLine());
//String B = reader.readLine();
StringTokenizer st = new StringTokenizer(reader.readLine());
int[] A = new int[N];
Queue Q = new LinkedList<>();
Queue P = new LinkedList<>();
for(int i=0;i<N;i++){

	            A[i] = Integer.parseInt(st.nextToken());
	            if(A[i] % 2 == 0){
	                Q.add(A[i]);
	            }
	            else
	                P.add(A[i]);
	            
	        
	        }
	        //int count=0;
	      //  for(int k=0;k<N;k++){
	      //      if(A[k] % 2 == 0){
	      //          System.out.print(A[k]+" ");
	      //      }
	        
	        
	        for(int i=0;i<Q.size();i++){
	                
	                int curr = Q.poll();
	                System.out.print(curr+" ");
	            
	        }
	        
	        for(int i=0;i<P.size();i++){
	                
	                int curr = P.poll();
	                System.out.print(curr+" ");
	            
	        }
	        
	        System.out.println("/n");
	      //  for(int i=0;i<count;i++){
	      //      for(int j=1;j<N;j++){
	      //          if(A[j] % 2 == 0){
	      //              int temp = A[i];
	      //              A[i] = A[j];
	      //              A[j] = temp;
	      //              break;
	      //          }
	      //      }
	      //  }
	      //  for(int i=0;i<N;i++){
	      //      System.out.print(A[i]);
	      //  }
	        T--;
	    }
	}
	catch(Exception e){
	    e.printStackTrace();
	}
}

}

can anyone please explain what is wrong with this?

Post your code with proper indentation or do one thing copy your code and paste in ideone or pastebin ,run it and share the link .
Nobody will be able to read your code , I bet even you will not be able to understand this code .

1 Like

XYL02r - Online Java Compiler & Debugging Tool - Ideone.com. This is the ideone link ,Is this fine?

Your code is not printing anything and basic idea or optimal strategy for this problem is to print all the even numbers together before odd numbers.

but i have given that print statement, try giving input

This is what he did, right?

System.out.println("/n");

You’re already using println(), why put '/n' again?
And btw, isn’t it '\n'?

1 Like

ohh, sorry my mistake, and else is it alright?

Make those changes and try submitting bro :slightly_smiling_face: