constk

Lab_4_HalfDivision_For

Oct 31st, 2019
199
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <iostream>
  4.  
  5. int main() {
  6. float Xstart, Xfinish, x, y, n, h;
  7. int i = 0;
  8.  
  9. printf("Please, input left limit: ");
  10. scanf("%f", &Xstart);
  11. printf("Please, input right limit: ");
  12. scanf("%f", &Xfinish);
  13. printf("Please, input increment: ");
  14. scanf("%f", &h);
  15.  
  16. if (Xstart > 9 || Xfinish < -5) {
  17. puts("Функция не определена на данном отрезке");
  18. }
  19. else {
  20. printf("\xC9\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCB\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xBB\n");
  21. printf("\xBA x \xBA y \xBA\n");
  22. n = (int)((Xfinish - Xstart) / h);
  23. x = Xstart;
  24. for (i = 0; i <= n; i++) {
  25. if (x <= 9 && x >= -5) {
  26. if ( x <= 0) {
  27. if (x <= -3) {
  28. y = x + 3;// [-5;-3]
  29. }
  30. else {
  31. y = sqrt(9 - x * x);// (-3;0)
  32. }
  33. }
  34. else {
  35. if (x <= 6) {
  36. y = -(x / 2) + 3;// (0;6]
  37. }
  38. else {
  39. y = x - 6; // (6;9]
  40. }
  41. }
  42. printf("\xBA\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xBA\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xBA\n");
  43. printf("\xBA%6.2f \xBA%6.2f \xBA\n", x, y);
  44. }
  45. x += h;
  46. }
  47. printf("\xC8\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCA\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xBA\n");
  48.  
  49. }
  50.  
  51. system("pause");
  52. return 0;
  53. }
RAW Paste Data