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

From AsIsWiki
Revision as of 15:11, 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 Task12 {

    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        
	System.out.println();
        System.out.println(" Решение системы уравнений:              ");
        System.out.println(" A * X + B * Y = C  и  D * X + E * Y = F ");
        System.out.println("-----------------------------------------");

        System.out.print(" Введите A B C D E F: "); 
	double a = in.nextDouble();
	double b = in.nextDouble();
	double c = in.nextDouble();
	double d = in.nextDouble();
	double e = in.nextDouble();
	double f = in.nextDouble();

        System.out.println("-----------------------------------------");

	if (a / d != b / e) {

	    double y = (f * a - d * c) / (e * a - d * b);
   	    double x = (c - b * y) / a;

	    System.out.printf(" Система имеет единственное решение X = %.2f, Y = %.2f\n", x, y);

	} else {
	    if (a / d == c / f) {

		System.out.println(" Система имеет бесконечно много решений");

	    } else {

		System.out.println(" Система не имеет решений");

	    }
	}
    }
}


C++



Pascal




Ветвление

Personal tools
Namespaces

Variants
Actions
Navigation
Tools