Http://www.cnblogs.com/shiyangxt/archive/2008/09/14/1290827.html
C language implementation source code for your reference!
Cosine function:
# Include <stdio. h>
# Include <math. h>
Void main ()
{
Double Y;
Int X, M;
For (y = 1; y> =-1; y-= 0.1)/* Y is the column direction, the value ranges from 1 to-1, and the step size is 0.1 */
{
M = ACOs (y) * 10;/* calculate the radian M corresponding to Y, multiply by 10 as the image magnification */
For (x = 1; x <m; X ++) printf ("");
Printf ("*");/* control the number * on the left side of the print */
For (; x <62-m; X ++) printf ("");
Printf ("*/N");/* control printing the symmetric right side of the same line */
}
}
Sine function:
# Include <stdio. h>
# Include <math. h>
Main (){
Double Y;
Int X, M, I;
Printf ("Y = sin (x) [0 <x <2 * Pi]/n ");
For (y = 1; y> =-1; y-= 0.1) {/* Y is the column direction, the value ranges from 1 to-1, and the step size is 0.1 */
If (Y> = 0 ){
M = Asin (y) * 10;/* calculate the radian M corresponding to Y, multiply by 10 as the image magnification */
For (x = 1; x <m; X ++) printf ("");
Printf ("*");/* control printing */
For (; x <31-m; X ++) printf ("");
Printf ("*/N");}/* control printing symmetric * numbers in the same row */
Else {
M =-1 * asin (y) * 10;
For (I = 0; I <32; I ++) printf ("");
For (x = 1; x <m; X ++) printf ("");
Printf ("*");
For (; x <31-m; X ++) printf ("");
Printf ("*/N ");
}
}
}