System.IndexOutOfRangeException - C# (178055)
Формулировка задачи:
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Диапазон x - y ");
int x = Convert.ToInt32(Console.ReadLine());
int y = Convert.ToInt32(Console.ReadLine());
int koli4estvo = y;
int a = 0;
int s4italka = 0;
double[] masiv = new double[s4italka];
for (int count = 0; count <= koli4estvo; ++count)
{
++s4italka;
++a;
double z = (x + a) / 2;
if (x + a == 0 )
{ Console.WriteLine("Соре"); }
if (x == 0 )
{ Console.WriteLine("Соре"); }
if (a == 0)
{ Console.WriteLine("Соре"); }
else
{
double res = Math.Sqrt(z);
Console.WriteLine(res);
masiv[s4italka] = res;
}
}Решение задачи: «System.IndexOutOfRangeException»
textual
Листинг программы
using System;
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
{
int N = 10;
int[] x = { 1, -4, -9, 5, -7, -9, 5, 3, 8, 0 };
int[] a = { 4, 4, -2, 5, 11, 3, -5, 0, -9, 2 };
for(int i=0; i<N; i++)
{
if(x[i]+a[i]>0)
Console.WriteLine(Math.Sqrt((x[i]+a[i])/2.0));
}
}
}
}