Практикум по программированию. Основы. Циклы. Поиск элементов ряда

From AsIsWiki
Revision as of 16:36, 4 April 2015 by Alex (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Циклы


Contents

Java

import java.util.Scanner;

public class Task03 {

    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        
	System.out.println();
        System.out.println(" Поиск элементов ряда:");
        System.out.println(" 1, 1 + 1/2, 1 + 1/2 + 1/3 ...");
        System.out.println("-------------------------------");

        System.out.print(" Введите границу поиска: "); 
	double x = in.nextDouble();

        System.out.println("-------------------------------");
        
	double y = 0;
	int i = 0;

	while (y <= x) {
	    y += 1.0 / ++i;
	}

	System.out.printf(" Y = %.12f\n", y);
    }
}


C++



Pascal




Циклы

Personal tools
Namespaces

Variants
Actions
Navigation
Tools