Отладка и тестирование приложений в среде Visual Studio 2005. Евсеева О.Н - 37 стр.

UptoLike

Составители: 

37
{
int z=1;
for (int i=1;n>=i;i++)
{
z = z*x;
}
return z;
}
[STAThread]
static void Main(string[] args)
{
int x;
int n;
try
{
Console.WriteLine("Введите число x:");
x=Convert.ToInt32(Console.ReadLine());
if ((x>=0) & (x<=999))
{
Console.WriteLine("Введите степень числа хчисло n:");
n=Convert.ToInt32(Console.ReadLine());
if ((n>=1) & (n<=100))
{
Console.WriteLine("Число х в степени n равно {0}", Power(x,n));
Console.ReadLine();
}
else
{
Console.WriteLine("Ошибка : n должно быть из отрезка [1..100]");
Console.ReadLine();
}
}
else
{
Console.WriteLine("Ошибка : x должно быть из отрезка [0..999]");
Console.ReadLine();
}
} \\ try-блок
catch (Exception e)
{
Console.WriteLine("Ошибка : вводите числа.");
Console.ReadLine();
}