Life, the Universe, and Everything

Why my code is not displaying correct answer

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long int a[1000];
	for(int i=0;i<5;i++)
	for(int j=0;j<5;j++)
	return 0;

If you will not mention the problem statement link, how can somebody help you?

You are taking the input upto 5 that’s the problem there it could be anything 1,2 even100000. You
have to take input untill you don’t find a stopping point .
More precisely You have to take input of array without knowing the array size .You should read this to know more about this

The thing is that you are taking only 5 inputs but there is nowhere mentioned in problem that there are only 5 inputs.

You will need to take input until you do not get 42 as a input.

Since we are not sure about the no. of times we need to take inputs therefore we can use,

while( cin >> x )

This loop reads elements from the input one after another, until there is no more data available in the input.

You are taking user input continuously and then checking for the conditions, but the statement is to check condition for every input as soon as it is entered.
while(true){ cin>>x; if(....) break; else cout<<x;


Thank you

okay thanks