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

From AsIsWiki
Revision as of 16:35, 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 Task01 {

    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        
	System.out.println();
        System.out.println(" Сумма квадратов чисел от 1 до N ");
        System.out.println("---------------------------------");

        System.out.print(" Введите N: "); 
	long n = in.nextLong();

        System.out.println("---------------------------------");
        
	long s = 0;

	for (long i = 1; i <= n; i++) {
	    s += i * i;
	}

	System.out.printf(" S = %d\n", s);
    }
}


C++



Pascal




Циклы

Personal tools
Namespaces

Variants
Actions
Navigation
Tools