VC++ 已知弦高,弦长,求半径,夹角, 弧度

编写过程简单:附代码

void CMyDlg::OnButton1() 
{
    // TODO: Add your control notification handler code here
    double H, L, r, A, C;

    CString str;
    ((CEdit *)(GetDlgItem(IDC_EDIT1)))->GetWindowText(str);  //拱高
     H = atof(str);
    ((CEdit *)(GetDlgItem(IDC_EDIT2)))->GetWindowText(str);  //弦长
     L = atof(str);
     
     if(H<=0 || L<=0)
     {
         AfxMessageBox("拱高,或弦长数值输入错误!!");
         return;
     }  

     ((CStatic *)(GetDlgItem(IDC_STATIC1)))->SetWindowText("0.0");  //0.0
     ((CStatic *)(GetDlgItem(IDC_STATIC2)))->SetWindowText("0.0");  //0.0
     ((CStatic *)(GetDlgItem(IDC_STATIC3)))->SetWindowText("0.0");  //0.0
     ((CStatic *)(GetDlgItem(IDC_STATIC4)))->SetWindowText("0.0");  //0.0

     r = H/2 + L*L/(8*H);
     str.Format("%0.3f", r);
     ((CStatic *)(GetDlgItem(IDC_STATIC1)))->SetWindowText(str);
     str.Format("%0.3f", r*2);
     ((CStatic *)(GetDlgItem(IDC_STATIC2)))->SetWindowText(str);

     A =2*asin((L/2)/r);
     str.Format("%0.3f", A*180/3.1415);
     ((CStatic *)(GetDlgItem(IDC_STATIC4)))->SetWindowText(str);

     C=A*r;
     str.Format("%0.3f", C);
     ((CStatic *)(GetDlgItem(IDC_STATIC3)))->SetWindowText(str);
}

推导过程

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值