Using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace ConsoleApplication5 { class Program { static void Main(string[] args) { // 1) Написать программу,которая вводит таблицу квадратов первых 10 чисел. for (int i = 1; i <= 10; i++) { Console.WriteLine(i + "^2=" + Math.Pow(i, 2)); }
Console.ReadKey();
// 2) Найти все натуральные числа а,b,с, из интервала от 1 до 10 для которых выполняется равенство а^2+b^2=c^2
for (int a = 1; a <= 10; a++) { for (int b = 1; b <= 10; b++) { for (int c = 1; c <= 10; c++) { if (Math.Pow(a, 2) + Math.Pow(b, 2) == Math.Pow(c, 2)) Console.WriteLine("a=" + a + "; b=" + b + "; c="+c); } } }
Console.ReadKey(); } } }
Koshovkina1721
18.12.2020
Class ArrayEven{ public static void main(String args[]){ java.util.Scanner in = new java.util.Scanner(System.in); long eArray[] = new long[1]; while((eArray[eArray.length-1] = in.nextLong())!=-1){ long nArray[] = new long[eArray.length+1]; for(int nCell = 0; nCell<eArray.length; nCell++)nArray[nCell]=eArray[nCell]; eArray = nArray; } eArrayCell: for(int cCell = 0; cCell<eArray.length-1; cCell++){ if(eArray[cCell]%2==1)continue; else for(int eCell = cCell+1; eCell<eArray.length-1; eCell++) if(eArray[eCell]%2==1){ eArray[eArray.length-1]=eArray[cCell]; eArray[cCell]=eArray[eCell]; eArray[eCell]=eArray[eArray.length-1]; continue eArrayCell; } break; } for(int cCell = 0; cCell<eArray.length-1; cCell++)System.out.print(eArray[cCell]+" "); } }
Ответить на вопрос
Поделитесь своими знаниями, ответьте на вопрос:
написать прогу на Python Напишите программу, которая ищет все пары дружественных чисел на отрезке [1;9999].
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
// 1) Написать программу,которая вводит таблицу квадратов первых 10 чисел.
for (int i = 1; i <= 10; i++)
{
Console.WriteLine(i + "^2=" + Math.Pow(i, 2));
}
Console.ReadKey();
// 2) Найти все натуральные числа а,b,с, из интервала от 1 до 10 для которых выполняется равенство а^2+b^2=c^2
for (int a = 1; a <= 10; a++)
{
for (int b = 1; b <= 10; b++)
{
for (int c = 1; c <= 10; c++)
{
if (Math.Pow(a, 2) + Math.Pow(b, 2) == Math.Pow(c, 2))
Console.WriteLine("a=" + a + "; b=" + b + "; c="+c);
}
}
}
Console.ReadKey();
}
}
}