+

来自「一次拟合算法,AD转换后的预处理算法,串口,定时器,积分,排序,三角形,延时,一」· 代码 · 共 38 行

TXT
38 行
字号
#include <REG52.H>                /* special function register declarations   */
                                  /* for the intended 8051 derivative         */

#include <stdio.h>                /* prototype declarations for I/O functions */
#include<math.h>
#define PI 3.1416

#ifdef MONITOR51                         /* Debugging with Monitor-51 needs   */
char code reserve [3] _at_ 0x23;         /* space for serial interrupt if     */
#endif                                   /* Stop Exection with Serial Intr.   */
                                         /* is enabled                        */
void main()
{
    float l,a,area,circle;

#ifndef MONITOR51
    SCON  = 0x50;		        /* SCON: mode 1, 8-bit UART, enable rcvr      */
    TMOD |= 0x20;               /* TMOD: timer 1, mode 2, 8-bit reload        */
    TH1   = 221;                /* TH1:  reload value for 1200 baud @ 16MHz   */
    TR1   = 1;                  /* TR1:  timer 1 run                          */
    TI    = 1;                  /* TI:   set TI to send first char of UART    */
#endif
while(1){
printf("please enter the hypo's length and angle:\n");
scanf("%f",&l);

scanf("%f",&a);
if (a>=PI/2)
printf("You enter a wrong angle\n");
else 
{area=l*l*sin(a)*cos(a);
circle=l*(1+sin(a)+cos(a));
printf("the area is %f and the circle is %f:\n",area,circle);}
}

 }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?