Advertisement
MeehoweCK

Untitled

Aug 10th, 2021
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. const double PI = 3.14159;
  7.  
  8. int main()
  9. {
  10.     double kat, radiany;
  11.     int n;
  12.     cout << "Podaj miare kata: ";
  13.     cin >> kat;
  14.     cout << "Wybierz:\n\t1. sinus,\n\t2. cosinus,\n\t3. tangens,\n\t4. cotangens\n";
  15.     cin >> n;
  16.  
  17.     // zamiana na radiany:
  18.     radiany = kat * PI / 180;
  19.  
  20.     while(n < 1 || n > 4)
  21.     {
  22.         cout << "Podales nieprawidlowa komende, wpisz jeszcze raz: ";
  23.         cin >> n;
  24.     }
  25.  
  26.     switch(n)
  27.     {
  28.     case 1:
  29.         cout << "Sinus kata " << kat << " stopni wynosi " << sin(radiany) << endl;
  30.         break;
  31.     case 2:
  32.         cout << "Cosinus kata " << kat << " stopni wynosi " << cos(radiany) << endl;
  33.         break;
  34.     case 3:
  35.         cout << "Tangens kata " << kat << " stopni wynosi " << tan(radiany) << endl;
  36.         break;
  37.     case 4:
  38.         cout << "Cotangens kata " << kat << " stopni wynosi " << 1 / tan(radiany) << endl;
  39.     }
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement