Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <conio.h>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. void display(int a, int b, char c)
  9. {
  10. string pom,pom2;
  11. float wynik;
  12. cout << " _______x______________y_______\n";
  13. cout << "| | |\n";
  14.  
  15. for (int i=a; i<=b; i++)
  16. {
  17. if (c=='a') wynik = sqrt(i);
  18. else if (c=='b') wynik = (1/(float)i);
  19. if(i<10) pom = " ";
  20. else if (i<100) pom = " ";
  21. else pom = "";
  22. if(wynik<10) pom2 = " ";
  23. else if (wynik<100) pom2 = " ";
  24. else pom2 = "";
  25. cout << "| "<< i << pom <<" |"<< pom2<<" "<< fixed <<setprecision(5) << wynik<<" |\n";
  26. }
  27. cout << "|_______________|______________|\n";
  28.  
  29. }
  30. char menu()
  31. {
  32.  
  33. char a;
  34. cout << " ______________________________\n";
  35. cout << "| |\n";
  36. cout << "| Wybierz rodzaj dzialania |\n";
  37. cout << "|______________________________|\n";
  38. cout << "| | |\n";
  39. cout << "| a) y=sqrt(x) | b) y=1/x |\n";
  40. cout << "|_______________|______________|\n";
  41. a=getch();
  42. return a;
  43. }
  44.  
  45. int main()
  46. {
  47. int a,b;
  48. char men = menu();
  49. cout << "Podaj poczatek i koniec predzialu <a,b>: ";
  50.  
  51.  
  52. cin >> a >> b;
  53. if ((men=='a') or (men=='b')) display(a,b,men);
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement