- #1
cstvlr
- 12
- 0
Homework Statement
Hi, I'm writing a c++ code which is about making an xy plane with dots and then using an array an plot a math function with a character. the functions i need to plot are sin x, sqrt x and a polynomial. so far I attempted to make a function for plotting sin x, but I always get it wrong, so I was wondering if anyone here help me out. also if i can have a clue of how i could go about the other function. thanks.
Homework Equations
The Attempt at a Solution
#include <iostream>
#include <cmath>
using namespace std;
const int Row = 21;
const int Col = 76;
const double PI = 3.14159;
int main()
{
char A[Row][Col];
for (int x=0 ; x < Row ; x++)
{
for (int y=0 ; y < Col ; y++)
{
A[x][y] = '.';
}
}
for (int i=0 ; i < Row ; i++)
{
for (int j=0 ; j < Col ; j++)
{
cout << A[j];
}
cout << "\n";
}
for(int q = 0; q < Row; q++)
{
for(int w = 0; w < Col; w ++)
{
w = 3.5 sin((double)PI* q);
A[q][w] = 'o';
}
}
for( int s = ( Row - 1); s >-1 ; s--)
{
for( int t = 1; t<Col; t++)
{
cout<< A;
cout<<endl;
}
}
return 0;
}
sin x would be plotted showing 'o' on the dots.