background image

#include <stdio.h>
#define PI 3.14159
#include <math.h>
void main()
{float a,b,sum;
a=30*PI/180;
b=60*PI/180;
sum=sin(a)+sin(b)+cos(a)+cos(60);
printf("total=%f\n",sum);
}
3、 比较两个数的大小。如果 x 大于 y,则输出:x>y,否则输出:x<y。
#include <stdio.h>
void main()
{int x,y;
scanf("%d,%d",&x,&y);
if(x>y)
  printf("x>y\n");
else
  printf("x<y\n");
 }

作业三

1、 输入 a、b、c 三个值,按从小到大排序输出。
#include <stdio.h>
void main()
{int a,b,c,t;
scanf("%d%d%d",&a,&b,&c);
  if(a>b)
  { t=b;
    b=a;
    a=t;
  }
  if(a>c)
  {t=a;
  a=c;
  c=t;
  }
  if(b>c)
  {t=b;b=c;c=t;}
  printf("%3d%3d%3d\n",a,b,c);
}.
2、 求自然数 1~10 之和。。
#include <stdio.h>
void main()