Циклы: вывести Квадрат и Куб для чисел из заданного интервала - C#
Формулировка задачи:
Помогите написать след задания :
Ввести a и b и вывести квадраты и кубы чисел от a до b.
Пример:
Введите границы интервала:
4 6
4 16 64
5 25 125
6 36 216
«5»: Вывести квадраты и кубы 10 чисел следующей последовательности: 1, 2, 4, 7, 11, 16, …
Пример:
1 1 1
2 4 8
4 16 64
...
46 2116 97336
1
Единственное , что я не знаю , как вывести в формате
4 16 64
5 25 125
Вот что у меня получилось
2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _69_2
{
class Program
{
static void Main(string[] args)
{
int a = 1;
while (a <= 10)
{
Console.WriteLine(a);
Console.WriteLine((a * a));
Console.WriteLine((a * a * a));
a += 2;
}
Console.ReadKey();
}
}
}using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _69
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Введите число a");
int a = int.Parse(Console.ReadLine());
Console.WriteLine("Введите число b");
int b = int.Parse(Console.ReadLine());
while (a <= b)
{
Console.WriteLine(a);
Console.WriteLine((a * a));
Console.WriteLine((a * a * a));
a++;
}
Console.ReadKey();
}
}
}Решение задачи: «Циклы: вывести Квадрат и Куб для чисел из заданного интервала»
textual
Листинг программы
Console.WriteLine("{0}\t{1}\t{2}", a, a * a, a * a* a);