Guest User

Untitled

a guest
Sep 30th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. // ConsoleApplication1.cpp: определяет точку входа для консольного приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <stdio.h>
  6. #include <windows.h>
  7. #include <locale.h>
  8. #include <iostream>
  9.  
  10.  
  11. int _tmain(int argc, _TCHAR* argv[])
  12. {
  13.  
  14.  
  15. int a, b, c = 0;
  16. int D = 0;
  17.  
  18. float x1, x2 = 0;
  19.  
  20. printf("enter a\n");
  21. std::cin >> a;
  22. printf("enter b\n");
  23. std::cin >> b;
  24. printf("enter c\n");
  25. std::cin >> c;
  26.  
  27. D = (b*b) + (-4 * a*c);
  28. if (D > 0)
  29. {
  30. printf("2 koren\n");
  31. x1 = (-b + sqrt(D)) / (2 * a);
  32. x2 = (-b - sqrt(D)) / (2 * a);
  33. std::cout << "1 koren: " << x1 << "\n2 koren: " << x2;
  34. }
  35. if (D == 0)
  36. {
  37. printf("1 koren");
  38. x1 = -(b / (2 * a));
  39. std::cout << "1 koren: " << x1;
  40.  
  41. }
  42. if (D < 0)
  43. {
  44. printf("no koren");
  45. }
  46.  
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment