Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.61 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <graphics.h>
  4. #include <math.h>
  5.  
  6. /*
  7.  * Author: MyZone
  8.  * Company: ZoneSofe Inc
  9.  * Date: 23.02.11
  10.  */
  11.  
  12. using namespace std;
  13.  
  14. char* toString(int number){
  15.     char* temp = new char[256];
  16.     return itoa(number,temp,10);
  17. }
  18.  
  19. long double formula(long double x, int a,int b){
  20.     double y0 = (5*x-9)/(7.5*a*b)+18;
  21.     if(y0>=0){
  22.         double y1 = 3*sqrt(y0);
  23.         double y2 = -2*x+0.5/a ;
  24.         double y3 = -exp(y2);
  25.    
  26.         return (y1 + y3)>300?301:(y1 + y3)<-300?-301:(y1 + y3);
  27.     }else return formula(x+1,a,b);
  28.     //return (x+15)*(x-5);
  29. }
  30.  
  31. void drawCoord(long double scale){
  32.     setcolor(8);
  33.        
  34.     line(0,300,960,300);
  35.     line(480,0,480,600);
  36.  
  37.     for(int i=0;i<600;i+=5*scale){
  38.         line(479,i,481,i);
  39.         if(!(i%(50/(int)scale))){
  40.             if(i-300) outtextxy(485,i,toString((300-i)/scale));          
  41.         }
  42.     }
  43.     for(int i=0;i<960;i+=5*scale){
  44.         line(i,299,i,301);
  45.         if(!(i%(50/(int)scale))){
  46.             if(i-480) outtextxy(i,305,toString((i-480)/scale));          
  47.             }
  48.     }
  49. }
  50. void draw(long double scale){
  51.     clearviewport();
  52.     drawCoord(scale);
  53.        
  54.     int a,b;
  55.     a=10;
  56.     b=100;
  57.    
  58.     setcolor(WHITE);    
  59.  
  60.     moveto(-1,(int)formula(-481,a,b));
  61.  
  62.     for(int x=-480;x<480;x++){
  63.         lineto(x+480,300-(int)formula(x/scale,a,b));
  64.     }
  65.  
  66.     outtextxy(0,0,"1 :");
  67.     outtextxy(20,0,toString(scale>1?scale:1));
  68. }
  69.  
  70.  
  71. int main(){
  72.     long double scale = 1;
  73.     initwindow(960,600);
  74.     draw(scale);
  75.  
  76.     for(;;){
  77.         char select = getch();
  78.         if(select=='[' || select=='1'){
  79.             if(scale<12) scale*=2;
  80.         }else if(select==']' || select=='2'){
  81.             if(scale>1) scale/=2;
  82.         }          
  83.         draw(scale);
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement