Last active
August 29, 2015 14:12
-
-
Save dhruvramani/17ed6f6cddc8c92d20de to your computer and use it in GitHub Desktop.
A program to generate a Sin Graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <math> | |
#define Length 75 | |
int main() | |
{ | |
char a[Length][Length]; | |
for(int i=0;i<Length;i++) | |
for(int j=0;j<Length;j++) | |
a[i][j]=' '; | |
for(int i=0;i<Length;i++) | |
a[Length/2][i]='_'; | |
int index=Length/2,angle=0,bo=1; | |
for(int i=0;i<Length;i++) | |
{ | |
double k=sin(angle*M_PI/180.0); | |
if(bo==1) | |
if(k==1) | |
bo=0; | |
else | |
index--; | |
if(bo==0) | |
if(k==-1) | |
bo=1; | |
else | |
index++; | |
a[index][i]='.'; | |
angle+=5; | |
} | |
for(int i=0;i<Length;i++) | |
{ | |
for(int j=0;j<Length;j++) | |
cout<<a[i][j]; | |
cout<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment