Практикум по программированию. Основы. Ветвление. Система уравнений
From AsIsWiki
Contents[hide] |
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 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++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | // g++ 4.2 #include <iostream> using namespace std; int main() { double a, b, c, d, e, f; cout << "\n Решение системы уравнений:\n" ; cout << " A * X + B * Y = C и D * X + E * Y = F\n" ; cout << "-----------------------------------------\n" ; cout << " Введите A B C D E F: " ; cin >> a >> b >> c >> d >> e >> f; cout << "-----------------------------------------\n" ; if (a / d != b / e) { double y = (f * a - d * c) / (e * a - d * b); double x = (c - b * y) / a; printf ( " Система имеет единственное решение X = %.2f, Y = %.2f" , x, y); } else if (a / d == c / f) { cout << " Система имеет бесконечно много решений" ; } else { cout << " Система не имеет решений" ; } cout << "\n\n" ; return 0; } |
Pascal
1 |
JavaScript
1 |