xxxxxxxxxx
import java.math.BigInteger;
import java.util.Scanner;
public class Chooser
{
BigInteger num;
public static BigInteger findNumber(Chooser c)
{
Scanner s = new Scanner(System.in);
while(true)
{
System.out.println("choose a number (greater than zero): ");
c.num = s.nextBigInteger();
if(c.num.compareTo(BigInteger.valueOf(0))>0)
break;
}
return c.num;
}
public String guess(BigInteger number)
{
Scanner s = new Scanner(System.in);
while(true){
System.out.println("enter a guess: ");
this.num = s.nextBigInteger();
if(this.num.compareTo(number) == 0)
return "your answer is correct";
else if(this.num.compareTo(number) == 1)
return "the correct answer is lower";
else// (this.num.compareTo(number)== -1)
return "the correct answer is higher";
}
}
public static void main(String[] args)
{
Chooser choose = new Chooser();
BigInteger num = Chooser.findNumber(choose);
String guess = choose.guess(num);
while(true){
if(!guess.equalsIgnoreCase("your answer is correct"))
{
System.out.println(guess);
guess = choose.guess(num);
}
else
{
System.out.println(guess);
return;
}
}
}
}
xxxxxxxxxx
import java.util.LinkedList;
import java.util.List;
class SuffixTrieNode {
final static int MAX_CHAR = 256;
SuffixTrieNode[] children = new SuffixTrieNode[MAX_CHAR];
List<Integer> indexes;
xxxxxxxxxx
import java.util.LinkedList;
import java.util.List;
class SuffixTrieNode {
final static int MAX_CHAR = 256;
SuffixTrieNode[] children = new SuffixTrieNode[MAX_CHAR];
List<Integer> indexes;
xxxxxxxxxx
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int n,i,j;
int[][] a=new int[50][50];
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=sc.nextInt();
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]>10 && a[i][j]!=20)
{
System.out.println("No");
return;
}
}
}
System.out.println("Yes");
}
}
xxxxxxxxxx
void rainbow_loop() { //2
idex++;
ihue = ihue + 10;
if (idex >= LED_COUNT/LED_FIZLINE) {
idex = 0;
}
if (ihue > 255) {
ihue = 0;
}
hsv_to_rgb(ihue*100, thissat, 255, leds[idex]);
LEDSshow();
}
xxxxxxxxxx
package train;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Please enter your name");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
System.out.println("Welcome" + name);
}
}
xxxxxxxxxx
void main()
{
int a,b,c=1;
scanf("%d",&a);
printf("%d! = ",a);
for (b=a;b>0;b--){
printf("%d * ",b);
c=c*b;
}
printf("\n = %d",c);
}
xxxxxxxxxx
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
HashMap<Integer,Boolean> m = new HashMap<>();
ArrayList<Integer> a = new ArrayList<>();
for(int i=0;i<N;i++)
{
int x = sc.nextInt();
while(m.containsKey(x))
{
x = x + 1;
}
m.put(x,true);
a.add(x);
}
int sum = 0;
for(int i=0; i<a.size();i++)
{
sum = sum + a.get(i);
}
System.out.print(sum);
}
xxxxxxxxxx
import java.util.Scanner;
class CodeChef
{
public static void(String args[])
{
Scanner s=new Scanner;
int t=s.nextInt();
for(int i=0;i<t;i++)
{
int a=s.nextInt();
int b=s.nextInt();
if(a!=0)
{
System.out.println(a*b)
}
else
{
System.out.println(a);
}
}
}
}