Загрузка данных
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
double x = sc.nextDouble();
double h = sc.nextDouble();
double a = sc.nextDouble();
double[] R = new double[n];
for (int i = 0; i < n; i++) {
int j = i + 1;
R[i] = 2.5 * Math.sin(a * x + j * j * h);
}
System.out.print("R={");
for (int i = 0; i < n; i++) {
System.out.printf("%.3f", R[i]);
if (i < n - 1) {
System.out.print("; ");
}
}
System.out.println("}");
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
double x = sc.nextDouble();
double h = sc.nextDouble();
double a = sc.nextDouble();
double[] R = new double[n];
for (int i = 0; i < n; i++) {
int j = i + 1;
R[i] = 2.5 * Math.sin(a * x + j * j * h);
}
int minIndex = 0;
for (int i = 1; i < n; i++) {
if (R[i] < R[minIndex]) {
minIndex = i;
}
}
int posIndex = -1;
for (int i = 0; i < n; i++) {
if (R[i] > 0) {
posIndex = i;
}
}
if (posIndex == -1) {
System.out.println("Нет положительного элемента");
} else {
int left = Math.min(minIndex, posIndex);
int right = Math.max(minIndex, posIndex);
for (int i = left + 1; i < right; i++) {
if (R[i] < 0) {
for (int j = i; j < n - 1; j++) {
R[j] = R[j + 1];
}
n--;
i--;
right--;
}
}
}
System.out.print("R={");
for (int i = 0; i < n; i++) {
System.out.printf("%.3f", R[i]);
if (i < n - 1) {
System.out.print("; ");
}
}
System.out.println("}");
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
double x = sc.nextDouble();
double h = sc.nextDouble();
double a = sc.nextDouble();
double[] R = new double[n];
for (int i = 0; i < n; i++) {
int j = i + 1;
R[i] = 2.5 * Math.sin(a * x + j * j * h);
}
// Поиск первого минимума
int minIndex = 0;
for (int i = 1; i < n; i++) {
if (R[i] < R[minIndex]) {
minIndex = i;
}
}
// Поиск последнего положительного
int posIndex = -1;
for (int i = 0; i < n; i++) {
if (R[i] > 0) {
posIndex = i;
}
}
// Удаление отрицательных
if (posIndex != -1) {
int left = Math.min(minIndex, posIndex);
int right = Math.max(minIndex, posIndex);
for (int i = left + 1; i < right; i++) {
if (R[i] < 0) {
for (int j = i; j < n - 1; j++) {
R[j] = R[j + 1];
}
n--;
i--;
right--;
}
}
}
// Вычисление среднего
double sum = 0;
int count = 0;
boolean found = false;
for (int i = 0; i < n; i++) {
if (R[i] < 0) {
found = true;
break;
}
sum += R[i];
count++;
}
if (!found || count == 0) {
System.out.println("Нет среднего значения");
} else {
double sr = sum / count;
System.out.printf("Sr=%.3f%n", sr);
}
}
}