SDITSCODERS SOLUTION
Calculate Area 2 Solution
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int l=in.nextInt();
int b=in.nextInt();
System.out.println(l*b);
}
}
Find the max 4 Solution
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
int [] ar=new int[10];
Scanner in=new Scanner(System.in);
for(int i=0;i<10;i++)
ar[i]=in.nextInt();
int max=ar[0];
for(int i=1;i<10;i++)
if(ar[i]>max)
max=ar[i];
System.out.println(max);
}
}
Arrow's Movement Solution
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String [] args)
{
Scanner in =new Scanner(System.in);
int x_in=in.nextInt();
int y_in=in.nextInt();
int n=in.nextInt();
int x=x_in,y=y_in;
int increment=1;;
for(int i=0;i<n;i++)
{
if(i%4==0)
{
x+=increment;
}
else if(i%4==1)
{
y+=increment;
}
else if(i%4==2)
{
x-=increment;
}
else
{
y-=increment;
}
increment++;
}
System.out.println(x+" "+y);
}
}
Thank you!
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int l=in.nextInt();
int b=in.nextInt();
System.out.println(l*b);
}
}
Find the max 4 Solution
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
int [] ar=new int[10];
Scanner in=new Scanner(System.in);
for(int i=0;i<10;i++)
ar[i]=in.nextInt();
int max=ar[0];
for(int i=1;i<10;i++)
if(ar[i]>max)
max=ar[i];
System.out.println(max);
}
}
Arrow's Movement Solution
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String [] args)
{
Scanner in =new Scanner(System.in);
int x_in=in.nextInt();
int y_in=in.nextInt();
int n=in.nextInt();
int x=x_in,y=y_in;
int increment=1;;
for(int i=0;i<n;i++)
{
if(i%4==0)
{
x+=increment;
}
else if(i%4==1)
{
y+=increment;
}
else if(i%4==2)
{
x-=increment;
}
else
{
y-=increment;
}
increment++;
}
System.out.println(x+" "+y);
}
}
Thank you!
Comments
Post a Comment