Найти сумму квадратов всех целых чисел от a до b (значения a и b вводятся с клавиатуры).
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace lab1_4{
class Program
{
static void Main(string[] args)
{
int a = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine()); // Перехватов Д. 09мос(у)
int s = 0;
while (a <= b)
{
s = s + a * a;
a++;
}
Console.Write(s);
}
}
}
15 сентября 2009, 22:06