This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
class Main { | |
public static void main(String[] args) throws Exception { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
String l = br.readLine(); | |
int c = 0; | |
for(int i = 0; i < 6; i++) { | |
if(l.charAt(i) == '1') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int n = sc.nextInt(); | |
int w = sc.nextInt(); | |
System.out.println((n * n) - w); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
String l1 = br.readLine(); | |
String l2 = br.readLine(); | |
int n = Integer.parseInt(l1); | |
int k = Integer.parseInt(l2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
class Xxfestival { | |
public static void main(String[] args) { | |
Scanner scan = new Scanner(System.in); | |
String str = scan.next(); | |
int l =str.length(); | |
System.out.println(str.substring(0, l-8)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
class LinearSearch { | |
static boolean search(int[] A, int n, int key) { | |
int i = 0; | |
//番兵法 | |
A[n] = key; | |
while(true) { | |
if(A[i] == key) { | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
class ArrayListDemo1 { | |
public static void main(String[] args) { | |
//1. addしてみる | |
ArrayList<Integer> array = new ArrayList<>(); | |
System.out.println("==========="); | |
System.out.println("Before add"); | |
System.out.println("==========="); | |
System.out.println("array size : " + array.size()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TimeMeasurement { | |
public static void main(String[] args) { | |
long start = System.nanoTime(); | |
// some processing | |
int[] a = {1,2,3,4,4,5,6,7,8,9,10}; | |
for(int i=0; i<a.length; i++){ | |
System.out.println(a[i]); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
class ConvertToIntArray { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("配列のサイズを入力してください。"); | |
int n = sc.nextInt(); | |
int[] A = new int[n]; | |
System.out.println("配列の要素を空白区切りで入力してください。"); | |
for(int i=0; i<n; i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Factorial { | |
//階乗を求める再帰関数 | |
static int factorial(int n) { | |
if(n==1) { | |
return 1; | |
} | |
return n * factorial(n-1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class SimilarArrays { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int n = sc.nextInt(); | |
int[] A = new int[n]; | |
for(int i=0; i<n; i++){ | |
A[i] = sc.nextInt(); | |
}; |
OlderNewer