Advertisement
Chdata

Untitled

Apr 18th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.94 KB | None | 0 0
  1.  
  2.  
  3.                                                                 #include <iostream>
  4.                                                                 #include  <iomanip>
  5.                                                                 #include   <limits>
  6.                                                           #include             <cctype>
  7.                                                           #include             <math.h>
  8.                                                           using /*HATS*/ namespace std;
  9.  
  10.                                                                  const  double Z =
  11.                                                                  3.14159265358979;
  12.                                                           int k4Mxty4 = 20;       double
  13.                                                           j(  double jk ) {       return
  14.                                            jk * (Z/180.0);} double b(double       h7){return h7*
  15.                                            (180.0/Z);} double d5w(double n)       {return (n < 0
  16.                               || fmod(n,1.0)!= 0.0)?-1:(n==1||n==0)?1:d5w(n-1)*n;}double oL3m(double g)
  17.                               {while(g<0.00){g+=360.0;}while (g > 360.0){g -= 360.0;}return g;}int r02(
  18.                   int n){return (n<0)?0:(n>20)?20:n;}double cYF54(double x,               bool o
  19.                   = 1){double r = 1.0;double q;int i = 1;do{q = r;r += pow(               -1.0,i)
  20.             *(pow(x,i*2.0)/d5w(i*2.0));i++;if(o){cout<<setfill(' ')                <<setw(
  21.             k4Mxty4 + 3 ) << q << " | " << setfill( ' ' ) << setw(                 k4Mxty4
  22.        +3)<<r<<" | Dif: "<<setfill(' ')<<setw(k4Mxty4+3) <<                (q- r)<<
  23.        "\n";}}while(q != r);return r;}template< typename i>                i win(){
  24.   i x;cin>>x;while(cin.fail()){cin.clear();std::cin.ignore(        /**lol*/
  25.   numeric_limits<streamsize>::max(),'\n');cout<<"\nY"; cout        <<"ou l"
  26.   <<"ose. Try again: "; cin >> x;} return x;}int main(){char ill1i=
  27.   'y';double frog; do{cout<<"Angle: ";frog=j(oL3m(win<double>( )));
  28.        cout<<"\n";cout << "Sigfigs: ";k4Mxty4 = r02(win<int>       ());cout
  29.        << "\n";cout<<setprecision(k4Mxty4)<<fixed;cout<<"co"       <<"s("<<
  30.                   setprecision(2)<<fixed <<      b(frog)<<") = "<<setprecision(k4Mxty4)
  31.                   <<fixed<<cYF54(frog)<<"."      <<"..\n\n";cout << "math.h cos() func"
  32.  
  33.  
  34.   <<"tion output: "      << setfill(' ') <<               setw(k4Mxty4+3)
  35.   <<cos(frog)<<"\n";     cout << "Differen"               <<"ce betwee"<<
  36.   "n fu"                 <<"n"       <<"ct"               <<"ion"    
  37.   <<"s:"                 <<" "<<    setfill(              ' ') <<
  38.   setw(k4Mxty4+3)<<      cYF54(frog,0)-cos(         frog)<<"\n\n";
  39.   cout<<"Again y/n"      <<"? ";ill1i=tolower       (win<char>());
  40.  
  41.  
  42.       cout << "\n";} while (ill1i == 'y');cout << "Press "<<
  43.       "Enter"<<" to Exit.";cin.ignore();cin.get();return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement