sin图像
#include"stdio.h"
#include"math.h"main()
{
double y;
int x,m;
for(y=1;y>=0;y-=0.1)
{
m=asin(y)*10;
for(x=0;x<m;x++)
printf(" ");
printf("*");
for(x=m;x<30-m;x++)
printf(" ");
printf("*\n");
}
for(y=0;y>=-1;y-=0.1)
{
m=asin(y)*10;
for(x=1;x<31.4-m;x++)
printf(" ");
printf("*");
for(x=31.4-m;x<62.8+m;x++)
printf(" ");
printf("*\n");
}
}
cos图像
#include"stdio.h"
#include"math.h"
main()
{
double y;
int x,m;
for(y=1;y>=-1;y-=0.1)
{
m=acos(y)*10;
for(x=1;x<m;x++)
printf(" ");
printf("*");
for(x=m;x<62-m;x++)
printf(" ");
printf("*\n");
}
}
sin与cos图像
#include <stdio.h>
#include <math.h>
int main()
{
double y;
int m;
int x;
int n;
for( y = 1;y >= -1;y -= 0.1)
{
m = acos(y) * 10;
n = asin(y) * 10;
if(n < 0)
{
n = -n + 31;
}
for(x = 0; x <= 62; x++)
{
if(x == n || x == 31 - n || x == 93 - n)
{
printf("+");
}
else if(x == m || x == 62 - m)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
sin与直线f(x)=45(y-1)+31
#include <stdio.h>
#include <math.h>
int main()
{
double y;
int m;
int x;
int n;
for( y = 2;y >= 0;y -= 0.1)
{
m = 45*(y-1)+31;
n = asin(1-y) * 10;
if(n < 0)
{
n = -n + 31;
}
for(x = 0; x <= 62; x++)
{
if(x == n || x == 31 - n || x == 93 - n)
{
printf("+");
}
else if(x == m )
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
编程前注意一些函数图像的特殊性,往往可以节约很多时间