Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <graphics.h>
- #include <math.h>
- /*
- * Author: MyZone
- * Company: ZoneSofe Inc
- * Date: 23.02.11
- */
- using namespace std;
- char* toString(int number){
- char* temp = new char[256];
- return itoa(number,temp,10);
- }
- long double formula(long double x, int a,int b){
- double y0 = (5*x-9)/(7.5*a*b)+18;
- if(y0>=0){
- double y1 = 3*sqrt(y0);
- double y2 = -2*x+0.5/a ;
- double y3 = -exp(y2);
- return (y1 + y3)>300?301:(y1 + y3)<-300?-301:(y1 + y3);
- }else return formula(x+1,a,b);
- //return (x+15)*(x-5);
- }
- void drawCoord(long double scale){
- setcolor(8);
- line(0,300,960,300);
- line(480,0,480,600);
- for(int i=0;i<600;i+=5*scale){
- line(479,i,481,i);
- if(!(i%(50/(int)scale))){
- if(i-300) outtextxy(485,i,toString((300-i)/scale));
- }
- }
- for(int i=0;i<960;i+=5*scale){
- line(i,299,i,301);
- if(!(i%(50/(int)scale))){
- if(i-480) outtextxy(i,305,toString((i-480)/scale));
- }
- }
- }
- void draw(long double scale){
- clearviewport();
- drawCoord(scale);
- int a,b;
- a=10;
- b=100;
- setcolor(WHITE);
- moveto(-1,(int)formula(-481,a,b));
- for(int x=-480;x<480;x++){
- lineto(x+480,300-(int)formula(x/scale,a,b));
- }
- outtextxy(0,0,"1 :");
- outtextxy(20,0,toString(scale>1?scale:1));
- }
- int main(){
- long double scale = 1;
- initwindow(960,600);
- draw(scale);
- for(;;){
- char select = getch();
- if(select=='[' || select=='1'){
- if(scale<12) scale*=2;
- }else if(select==']' || select=='2'){
- if(scale>1) scale/=2;
- }
- draw(scale);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement