upd
This commit is contained in:
41
java/entrance-exams/coding/Main.java
Normal file
41
java/entrance-exams/coding/Main.java
Normal file
@@ -0,0 +1,41 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
task2();
|
||||
}
|
||||
|
||||
static void task1() {
|
||||
Scanner input = new Scanner(System.in);
|
||||
String data = input.nextLine();
|
||||
|
||||
int day1 = Integer.parseInt(data.split(" ")[0]);
|
||||
int day2 = Integer.parseInt(data.split(" ")[1]);
|
||||
|
||||
if (day1 > 7) {
|
||||
System.out.println(day1 - 7);
|
||||
} else {
|
||||
System.out.println(day2 + 7);
|
||||
}
|
||||
}
|
||||
|
||||
static void task2() {
|
||||
Scanner input = new Scanner(System.in);
|
||||
String data = input.nextLine();
|
||||
|
||||
int cntA = 0, cntAB = 0, cntABC = 0;
|
||||
|
||||
for (char c : data.toCharArray()) {
|
||||
if (c == 'a') {
|
||||
cntA++;
|
||||
} else if (c == 'b') {
|
||||
cntAB += cntA;
|
||||
} else if (c == 'c') {
|
||||
cntABC += cntAB;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(cntABC);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user