For16. Дано вещественное число A и целое число N (> 0). Используя один цикл, вывести все целые степени числа A от 1 до N.
>Решение Pascal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | program For16; var A,Rez:Real; N, i :Integer; begin Write('Введите A: '); Readln(A); Write('Введите N: '); Readln(N); Rez:=1; For i:=1 to N do begin Rez:=Rez*A; Writeln(Rez); end; end. |
Решение C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <stdio.h> int main(void) { float a; printf("A:"); scanf ("%f", &a); int n; printf("N:"); scanf ("%i", &n); float rez=1; int i; for (i =1; i<=n; ++i){ rez *= a; printf("%f \n ",rez); } return 0; } |
Решение C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <iostream> using namespace std; int main() { float a; cout << "A:"; cin >> a; int n; cout << "N:"; cin >> n; float rez=1; int i; for (i =1; i<=n; ++i){ rez *= a; cout << rez << endl; } return 0; } |
Решение C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | using System; namespace ConsoleApp { class Program { static void Main(string[] args) { Console.Write("a="); double a = Convert.ToDouble(Console.ReadLine()); Console.Write("n="); int n = Convert.ToInt32(Console.ReadLine()); double result = 1; for (int i = 1; i <= n; i++) { result *= a; Console.WriteLine(result); } Console.ReadKey(); } } } |
>
Решение Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | package abramyan; import java.util.Scanner; public class Abramyan { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("a="); double a = in.nextDouble(); System.out.print("n="); int n = in.nextInt(); int result = 1; for (int i = 1; i <= n; i++) { result *= a; System.out.println(result); } in.close(); } } |
ГДе С++
Решение на C++ добавлено
Не правильно
Где Python
сделайте на kotlin
питон
a = int(input())
n = int(input())
for i in range(1, n + 1):
print(a ** i)