Java Saved Program: kind-mountain

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


import java.util.*;
import java.io.*;
class Script
{
public static void main(String args[])
{
Scanner sn=new Scanner(System.in);

int testCase=sn.nextInt();
int a[]={1,2,3,4};
int c=0;
int n;
while(testCase!=0)
{
 n=sn.nextInt();
c=0;
for(int j=0;j<a.length;j++)
{
for(int k=0;k<a.length;k++)
{
if(a[j]==4)
{
a[j]=1;
}
if(a[k]==4)
{
a[k]=1;
}
if(a[j]+a[k]==n)
{
c++;
}
}
}
System.out.println(c);
testCase--;
}
}
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs