Codechum
Codechum
import java.util.Scanner;
class Main {
public static void main(String[] args) {
int[] nums = new int[]{
-2, 1, 1, 2, 3,
9, 10, -3, 100, 2,
4, -5, 1, 10, -100,
5, 2, 3, -1, 1,
-3, -4, -5, -6, -7,
9, 9, 9, 9, 9,
1, 2, 3, 4, 5,
100, 100, 100, 100, 100
};
import java.util.Scanner;
class Main {
public static void main(String[] args) {
double[] nums = new double[]{1.4, 1.2054, 2.2, 2.5, 3.66, 3.0, 4.024,
4.00001, 5.5, 5.10};
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter # of rows: ");
int row = in.nextInt();
System.out.print("Enter # of columns: ");
int col = in.nextInt();
int[][] arr = new int[row][col];
System.out.println("Elements:");
for(int i = 0; i<row; i++){
for(int j=0; j<col; j++){
arr[i][j]=in.nextInt();
}
}
System.out.print("Enter the boogeyman's value: ");
int bog = in.nextInt();
}
}
class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter # of rows: ");
int row = in.nextInt();
System.out.print("Enter # of columns: ");
int col = in.nextInt();
int[][] arr = new int[row][col];
System.out.println("Enter elements:");
for(int i = 0; i<row; i++){
for(int j=0; j<col; j++){
arr[i][j]=in.nextInt();
}
}
int count=0;
for(int i = 0; i<row; i++){
int sum=0;
for(int j=0; j<col; j++){
sum=sum+arr[i][j];
}
if(sum%2==0){
count++;
break;
}
}
System.out.print("Even row: "+count);
}
}
}
}
}
Functions
import java.util.Scanner;
class Main {
public static int askInput() {
Scanner scan = new Scanner(System.in);
return number;
}
import java.util.Scanner;
class Main {
public static int askInput() {
Scanner scan = new Scanner(System.in);
return number;
}
public static void main(String[] args) {
askInput();
}
}
import java.util.Scanner;
class Main {
public static int palindrome(int number) {
Scanner scan = new Scanner(System.in);
palindrome(0);
}
}
import java.util.Scanner;
class Main {
public static void palindrome()
{
Scanner scan = new Scanner(System.in);
String reverseStr = "";
System.out.print("Enter a string: ");
String str = scan.nextLine();
int strLength = str.length();
if(str.toLowerCase().equals(reverseStr.toLowerCase()))
palindrome();
}
}
import java.util.Scanner;
class Main {
public static int compare(int a, int b){
if(a>b){
return a;
} else if (a<b){
return b;
}
return 0;
}
char a, b;
import java.util.Scanner;
class Main {
public static int compare(int a, int b, int c){
int a, b, c;
class Main {
public static void fun(int n) {
if (n > 0) {
fun(n-1);
if(n%2==0){
System.out.print(n+" ");
}
}
}
import java.util.Scanner;
class Main{
public static void factorial(int num){
int i,fact=1;
for(i=1;i<=num;i++){
fact=fact*i;
}
System.out.println(fact);
}
class Main {
public static void main(String[] args) {
char[] array = new char[]{
'x','s','q','a','y','i','u','o','p','a','w','q'
};
vowelCount(array);
}
static void vowelCount(char[] array){
int count=0;
for(int i=0; i<array.length; i++){
if(array[i]=='a' || array[i]=='e' || array[i]=='i' || array[i]=='o' ||
array[i]=='u'){
count++;
}
}
System.out.println("Number of vowels: "+ count);
}
}
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
}
}
return max;
}
}
class Main {
public static void main(String[] args) {
int[][] array = new int[][]{
{1, 6, 4},
{7, 2, 8},
{5, 9, 3}
};
int row=array.length;
int col=array[0].length;
displayElements(array, row, col);
}
static void displayElements(int[][] arr, int rows, int cols) {
for(int i = 0; i < rows; i++) {
for(int j = 0; j < cols; j++) {
System.out.printf("%d ", arr[i][j]);
}
System.out.println();
}
}
}
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[][] arr = new int[3][3];
int rows=arr.length;
int cols=arr[0].length;