




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include #include#includefloat delte,gh,a1,a2,b1,b2,c1,c2,d1,n;using namespace std; int MinY(int kb,int ke) int min, max; int r; max=kbke?kb:ke; min=kbke?kb:ke; if (max%min=0) return max; while(max%min!=0) r=max%min; max=min; min=r; return kb*ke/min; int main() float x1ans1,x1ans2,x1a,x1b,x1c;cout*nendl;cout 欢迎进入JWC方程求解系统nendl;cout*nendl;cout1.一元一次方程endl;cout对于 ax+b=c,; coutx1a; coutx1b; coutx1c;x1ans1=x1c-x1b; coutendl x1ax+x1b=x1cendl;cout解: x1ax=;printf(%.1fn,x1ans1); x1ans2=x1ans1/x1a;cout x=;printf(%.1fn,x1ans2);coutendlendlendl;cout2.一元二次方程endl;float x2ans1,x2ans2,a,b,c,k=0;cout对于 ax2+bx+c=0,endl; couta; coutb; coutc;if (c=0) k=2;x2ans1=b*b-4*a*c;coutendl ax2+bx+c=0endl;cout a=a ,b=b ,c=cendl;delte=x2ans1;cout0) cout0endl;gh=sqrt(delte);a1=0-b+gh;a2=0-b-gh;d1=2*a;c1=a1/d1;c2=a2/d1; cout x1=; printf(%.2fn,c1); cout x2=; printf(%.2fn,c2);if (delte=0) cout =0endl;gh=sqrt(delte);a1=0-b;d1=2*a;c1=a1/d1; cout x=; printf(%.2fn,c1);if (delte0) cout 0endl; cout 此方程无实数根!endl;coutendlendl; cout3.二元一次方程(整数)endl; float ka,kb,kc,kd,ke,kf,xy,xy8,xy9,ans1,ans2,ans3,ans4,q,p; int y1,y2,y3;cout对于 ax+by=c,endl; cout dx+ey=fendl; coutka; coutkb;coutkc; coutkd;coutke; coutkf; coutendl kax+kby=kc-endl;cout kdx+key=kf-endlendl; xy=MinY(kb,ke); y1=xy/kb; y2=xy/ke;ka=ka*y1; kb=kb*y1; kc=kc*y1;kd=kd*y2; ke=ke*y2; kf=kf*y2;cout解: *y1,得: kax+kby=kc-endl;cout *y2,得: kdx+key=kf-endl;ans1=kd-ka; ans2=kf-kc;cout -,得: ans1x=ans2-endl;ans4=ans2/ans1;cout /ans1,得: x=;printf(%.2f,ans4);cout-endl;cout 代入,得: ;q=ans4*ka;printf(%.2f,q);cout+kby=kc-endl; p=(kc-q)/kb; cout 化简,得: y=;printf(%.2f,p);coutendl 即: x=;printf(%.2f,ans4); coutendl y=;printf(%.2f,p); coutendlendlendl; cout4.分式方程(整数) endl;float ma,mb,mc,md,me,delte2,p1,p2,p3,kkkk;cout对于 b/(a+x)+c=e/(x+d),endl; coutma; coutmb;coutmc; coutmd;coutme; coutendl mb/(ma+x)+mc=me/(x+md)endl;cout解: 方程两边同乘(x+ma)(x+md),得endl;cout mb*(x+md)+mc*(x+ma)*(x+md)=(x+ma)*meendl;p1=mb+ma*mc+mc*md-me;p2=mb*md+ma*mc*md-ma*me; cout 即 mcx2+p1x+p2=0; cout a=mc ,b=p1 ,c=p2endl; if (mc!=0) p3=p1*p1-4*mc*p2;delte2=p3;float gh2,ma1,ma2,md1,mc1,mc2;cout0) cout0endl;gh2=sqrt(delte2);ma1=0-p1+gh2;ma2=0-p1-gh2;md1=2*mc;mc1=ma1/md1;mc2=ma2/md1;if (mc1+ma=0|mc1+md=0)coutx1=;printf(%.2f,mc1);if (mc2+ma=0|mc2+md=0)coutx2=;printf(%.2f,mc2);cout 检验:当x=; printf(%.2f,mc1); cout或; printf(%.2f,mc2); cout时,(x+ma)(x+md)=0,因此x=; printf(%.2f,mc1); cout或; printf(%.2f,mc2); cout不是原方程的解.endl; cout 所以,原分式方程无解.endl; if (mc2+ma!=0|mc2+md!=0) cout x2=; printf(%.2fn,mc2); cout 检验:当x=; printf(%.2f,mc1); cout时,(x+ma)(x+md)=0,因此x=; printf(%.2f,mc1); cout不是原方程的解;endl; cout 当x=; printf(%.2f,mc2); cout时,(x+ma)(x+md)0; cout 所以,原分式方程的解为x=; printf(%.2fn,mc2); if (mc1+ma!=0|mc1+md!=0) cout x1=; printf(%.2fn,mc1);if (mc2+ma!=0|mc2+md!=0) cout x2=; printf(%.2fn,mc2); cout 检验:当x=; printf(%.2f,mc1); cout或; printf(%.2f,mc2);cout时,(x+ma)(x+md)0endl; cout 所以,原分式方程的解为x1=; printf(%.2f,mc1); cout,x2=; printf(%.2fn,mc2);if (mc2+ma=0|mc2+md=0) cout x2=; printf(%.2fn,mc2); cout 检验:当x=; printf(%.2f,mc1); cout时,(x+ma)(x+md)0,因此x=; printf(%.2f,mc1); cout 当x=; printf(%.2f,mc2); cout时,(x+ma)(x+md)0,因此x=; printf(%.2f,mc2); cout不是原方程的解.endl; cout 所以,原分式方程的解为x=; printf(%.2fn,mc1); if (delte2=0) cout =0endl;gh2=sqrt(delte2);ma1=0-p1;md1=2*mc;mc1=ma1/md1;if (mc1+ma=0|mc1+md=0)cout x=;printf(%.2fn,mc1);cout 检验:当x=; printf(%.2f,mc1);cout时,(x+ma)(x+md)=0,因此x=;printf(%.2f,mc1);cout不是原方程的解.endl; cout 所以,原分式方程无解.endl; if (mc1+ma!=0|mc1+md!=0)cout x=; printf(%.2fn,mc1); cout 检验:当x=; printf(%.2f,mc1);cout时,(x+ma)(x+md)0;cout 所以,原分式方程的解为x=; printf(%.2fn,mc1); if (delte20) cout 0endl; cout 此分式方程无解!endl; if (mc=0) cout 即 p1x=p2*-1endl; cout 解得 x=; float ww1,ww2,ww3;ww1=p2*-1;ww2=ww1/p1;if (ww2+ma=0|ww2+md=0)cout 检验:当x=; printf(%.2f,ww2);cout时,(x+ma)(x+md)=0,因此x=
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 华三考试题库及答案
- 森林火警法律知识培训课件
- 桩基全护筒跟进施工课件
- 桥脑病变MRI课件
- 桥梁隧道冲刺课件
- 2025年技能提升跨行业通-用招聘笔试模拟题及答案
- 2025年陪诊师考试知识点探讨与试题及答案
- 2025年验船师考试(C级船舶检验专业实务)复习题及答案二
- 2025年航空公司面试空中乘务员能力预测试题集
- 2025年物流经理专业面试题解答技巧
- 供应商改善计划表
- DLT 5285-2018 输变电工程架空导线(800mm以下)及地线液压压接工艺规程
- 中国省市县行政区划
- DB11-T 1253-2022 地埋管地源热泵系统工程技术规范
- 管道工程施工重难点分析及应对措施
- JBT 7043-2006 液压轴向柱塞泵
- 体育公园运营可行性方案
- 《直升机构造与系统》课件-直升机的类型
- 成都第四十九中学数学新初一分班试卷含答案
- 《平方根》(第1课时)示范公开课教学设计【北师大版八年级数学上册】
- 《信息检索与处理(修订版)》课件下 第2单元第二课 分析信息-第3单元 综合探究实践活动
评论
0/150
提交评论