Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Уймин Максим
- //IT School, 2 группа
- //09.10.2015
- //Задача 5. Заполнить массив значениями членов арифметической прогрессии по формуле, заданной учителем
- import java.io.PrintStream;
- import java.util.Scanner;
- public class Exercise_5 {
- public static PrintStream out = System.out;
- public static Scanner scan = new Scanner(System.in);
- public static void MainFunction (){
- //Функция создаёт массив и заполняет его членами арифметической прогресси по формуле, введённой с клавиатуры
- out.println("Enter the array size(intger number, greather then zero)");
- int N = scan.nextInt();
- int[] array=new int [N];
- out.println("Formula of arithmetic progression is a[n] = a[1] + d(n-1)");
- out.println("Enter the a[1]");
- int a = scan.nextInt();
- out.println("Enter the d");
- int d = scan.nextInt();
- for (int i=0;i<N;i++){
- array[i] = a;
- a = a+d;
- out.print(array[i]+"\t");
- }
- }
- public static void main (String [] args){
- //Основная функция, отсюда начинается выполнение приложения
- MainFunction();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement