Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <conio.h>
- #include <iomanip>
- using namespace std;
- void display(int a, int b, char c)
- {
- string pom,pom2;
- float wynik;
- cout << " _______x______________y_______\n";
- cout << "| | |\n";
- for (int i=a; i<=b; i++)
- {
- if (c=='a') wynik = sqrt(i);
- else if (c=='b') wynik = (1/(float)i);
- if(i<10) pom = " ";
- else if (i<100) pom = " ";
- else pom = "";
- if(wynik<10) pom2 = " ";
- else if (wynik<100) pom2 = " ";
- else pom2 = "";
- cout << "| "<< i << pom <<" |"<< pom2<<" "<< fixed <<setprecision(5) << wynik<<" |\n";
- }
- cout << "|_______________|______________|\n";
- }
- char menu()
- {
- char a;
- cout << " ______________________________\n";
- cout << "| |\n";
- cout << "| Wybierz rodzaj dzialania |\n";
- cout << "|______________________________|\n";
- cout << "| | |\n";
- cout << "| a) y=sqrt(x) | b) y=1/x |\n";
- cout << "|_______________|______________|\n";
- a=getch();
- return a;
- }
- int main()
- {
- int a,b;
- char men = menu();
- cout << "Podaj poczatek i koniec predzialu <a,b>: ";
- cin >> a >> b;
- if ((men=='a') or (men=='b')) display(a,b,men);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement