Advertisement
Infernale

NCTU LAB 02/04 NUM 4

Apr 2nd, 2019
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Point{
  5.     int x, y;
  6. }point;
  7.  
  8. char sign_sin(Point p){
  9.     if(p.y>0){
  10.         return '+';
  11.     }else{
  12.         return '-';
  13.     }
  14. }
  15.  
  16. char sign_cos(Point p){
  17.     if(p.x>0){
  18.         return '+';
  19.     }else{
  20.         return '-';
  21.     }
  22. }
  23.  
  24. char sign_tan(Point p){
  25.     if(p.x>0 && p.y>0 || p.x<0 && p.y<0){
  26.         return '+';
  27.     }else{
  28.         return '-';
  29.     }
  30. }
  31.  
  32. int main(){
  33.     int x, y;
  34.     while(cin >> x >> y){
  35.         if(x==0 || y==0){
  36.             cout << "Invalid point! either x or y located in their axis. Enter a new point : " << endl;
  37.             continue;
  38.         }
  39.         point.x = x;
  40.         point.y = y;
  41.         cout << "sin " << sign_sin(point) << endl;
  42.         cout << "cos " << sign_cos(point) << endl;
  43.         cout << "tan " << sign_tan(point) << endl;
  44.     }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement