Function IsArmstrong(m As Long) As Boolean
Dim s As Long, n As Integer, i As Integer, m1 As Long
Dim d(1 To 15) As Long
m1 = m: n = 0
Do While m1 > 0
n = n + 1
d(n) = m1 Mod 10
m1 = Int(m1 / 10)
Loop
s = 0
For i = 1 To n
s = s + d(i) ^ n
Next i
IsArmstrong = (s = m)
End Function
Sub Test()
Dim k As Long, i As Long, j As Integer
Cells.Clear
k = CLng(InputBox("Введите значение k"))
j = 1
For i = 0 To k
If IsArmstrong(i) Then
Cells(j, 1) = i
j = j + 1
End If
Next i
End Sub
Function Compare(a,b:integer):char;
begin
if a<b then Compare:='<'
else if a=b then Compare:='='
else Compare:='>'
end;
var
x,y:integer;
begin
Write('Введите два числа через пробел: ');
Readln(x,y);
Writeln(x,Compare(x,y),y)
end.
Using System;
namespace Fractions{ public struct Fraction : IComparable<Fraction> { public Fraction(int numerator, int denominator) { Numerator = numerator; Denominator = denominator; }
public int Numerator; public int Denominator;
public int CompareTo(Fraction other) { return (Numerator * other.Denominator).CompareTo(other.Numerator * Denominator); } }
public class Program { static void Main(string[] args) { int numerator, denominator;
Console.Write("Числитель первой дроби "); numerator = int.Parse(Console.ReadLine()); Console.Write("Знаменатель первой дроби "); denominator = int.Parse(Console.ReadLine()); var fraction1 = new Fraction(numerator, denominator);
Console.Write("Числитель второй дроби "); numerator = int.Parse(Console.ReadLine()); Console.Write("Знаменатель второй дроби "); denominator = int.Parse(Console.ReadLine()); var fraction2 = new Fraction(numerator, denominator);
var compareResult = fraction1.CompareTo(fraction2); if (compareResult < 0) Console.WriteLine("<"); else if (compareResult > 0) Console.WriteLine(">"); else // = 0 Console.WriteLine("="); } }}
Var
A,B:integer;
P:real;
Begin
P:=1;
Write('A = ');Read(A);
Write('B = ');Read(B);
For A:=A to B do
P:=P*A;
WriteLn(P)
End.
Static void CountArray(int[] a)
{
var s = 0;
var k1 = 0;
var k2 = 0;
foreach(var t in a)
{
if (t > 0)
{
s += t;
k1 += (t % 2 == 1) ? 1 : 0;
k2 += (t > 10) ? 1 : 0;
}
}
Console.WriteLine($"{s} {k1} {k2}");
}