先给出第三题:
#include <stdio.h>
#include <math.h>
#define PAI 3.141592653
#define HEADER1 " **********************************\n"
#define HEADER2 " 1:sin() 2:cos()\n"
#define HEADER3 " 3:tan() 4:ctan()\n"
#define HEADER4 " **********************************\n"
#define HEADER5 " Please choose a number from1 to 4:\n"
int main()
{
char choose;
float x;
printf("请输入角度值(如:角度为60°就输入数60):");
scanf("%f",&x);
x=x*PAI/180 ;
printf(HEADER1);
printf(HEADER2);
printf(HEADER3);
printf(HEADER4);
printf(HEADER5);
fflush(stdin);
scanf("%c",&choose);
switch(choose)
{
case '1':
{
printf("%f\n",sin(x));
break;
}
case '2':
{
printf("%f\n",cos(x));
break;
}
case '3':
{
printf("%f\n",tan(x));
break;
}
case '4':
{
printf("%f\n",cos(x)/sin(x));
break;
}
}
fflush(stdin);
getchar();
}