public class Test { public static void Main() { double a, b, x, p=1; int k=0; Console.Write("a = "); a = double.Parse(Console.ReadLine()); Console.Write("b = "); b = double.Parse(Console.ReadLine()); for (int i=1; i <= 8; i++) { x = double.Parse(Console.ReadLine()); if ((x>=a)&&(x<=b)){ k++; p*=x; } } Console.WriteLine("k = {0} p = {1}", k,p); Console.ReadKey(); } }
Пример: a = 3 b = 8 7 9 2 0 6 4 3 5 k = 5 p = 2520
public class Test
{
public static void Main()
{
double a, b, x, p=1;
int k=0;
Console.Write("a = ");
a = double.Parse(Console.ReadLine());
Console.Write("b = ");
b = double.Parse(Console.ReadLine());
for (int i=1; i <= 8; i++) {
x = double.Parse(Console.ReadLine());
if ((x>=a)&&(x<=b)){
k++; p*=x;
}
}
Console.WriteLine("k = {0} p = {1}", k,p);
Console.ReadKey();
}
}
Пример:
a = 3
b = 8
7
9
2
0
6
4
3
5
k = 5 p = 2520