13 / 41
May 2014

Welcome! Please use code tags when posting code. What language is this? What error is the judge returning?

[quote="leppy"]Hello leppy... This is Java.. I am new to programming world and I don't know about code tags.. Can you figure out the issue? Thanks for your response.

Your code should look like this.
click on code tag and paste your code between them.
and on SPOJ you should not use public before class if you are using public you class name should be main.

Your algorithm is completely wrong, what problem is asking is you have to print all number until you encounter 42 in the input. Input can be any integer value it is not only between 1 and 100,and no need to print Started or finished in the output you have to print only those things which problem is asking for.

Hope this helps.

class Life 
{
	int inputArray[];
	Life(int a[])
	{
		inputArray=a;
	}
	void printResult()
	{
		System.out.println("Started");
		//System.out.println(inputArray[0]);
		for(int i=0;i<=inputArray.length-1;i++)
		{
			if(inputArray[i]==42 &&(inputArray[i]>99)&&(inputArray[i]<-99))
			break;
			System.out.println(inputArray[i]);
		}
	System.out.println("FINISHED");
	}
	public static void main(String[] args)
	{
		int c[]={1,3,4,5,1,2,3,7,8,9,0,1,2,3,42,4,5,6,7,8,4};
		Life ob=new Life(c);
		ob.printResult();
	}
}

Hi Laxman...I have changed the code as directed by you and still getting the the wrong answer...

class Main {
	int inputArray[];
	Main(int a[]){
		inputArray=a;
	}
	void printResult(){
		for(int i=0;i<=inputArray.length-1;i++){
			if(inputArray[i]==42)
				break;
			System.out.println(inputArray[i]);
		}
	}
	public static void main(String[] args) {
		int c[]={42,3,4,5,1,2,3,7,8,9,0,1,2,3,4,5,6,7,8,4};
		Main ob=new Main(c);
		ob.printResult();
		}
	}

what is this "int c[]={42,3,4,5,1,2,3,7,8,9,0,1,2,3,4,5,6,7,8,4};"

your code prints nothing.

how you are reading the input? what are you doing with "c[]".

Read the problem statement once again.

Still you don't understand what problem is asking for.
answer my question.-->How you are reading the input?

Thanks for your help.. But,I think that they should be more worried about logic instead of the source of input...Anyways I will take care of all the things that you have told me and try to solve some good problems.

How come the judge understand your logic until you process the given input and print the desired output..

I don't understand what actually you are trying to do.

anyway..good luck. smiley

What is the input constraint for this problem???I am getting a run time error..
question question question

If you are looking for a maximum on the number of integers in the input, there is none. There could be 5, there could be one billion.

2 years later

Hi everyone, i don't understand what is wrong in my code... if someone can help me...

#include <stdio.h>

int main(){
    int num;
    do {
        scanf("%d", &num);
        printf("%d", num);
    } while(num != 42);

    return 0;
}
  1. You have to print each number on a separate line
  2. The number 42 must not appear in the output