C 编程 科学计算器Word下载.docx
- 文档编号:21266627
- 上传时间:2023-01-29
- 格式:DOCX
- 页数:18
- 大小:16.92KB
C 编程 科学计算器Word下载.docx
《C 编程 科学计算器Word下载.docx》由会员分享,可在线阅读,更多相关《C 编程 科学计算器Word下载.docx(18页珍藏版)》请在冰豆网上搜索。
intflag=0;
//开始标志
intsp=0;
//判断除数为零时移除监听
intmax=0;
//范围标识
inteq=0;
#region功能键
privatevoidon_Click(objectsender,EventArgse)//开始
flag=1;
sp=0;
max=0;
this.numInput.Text="
0"
;
this.txtInput.Text="
"
privatevoidoff_Click(objectsender,EventArgse)//关闭
flag=0;
privatevoidbutton9_Click(objectsender,EventArgse)//删除
if(flag==1&
&
sp==0)
stringnumstring=this.numInput.Text;
if(numstring.Length>
0)
stringtemp=numstring.Substring(0,numstring.Length-1);
this.numInput.Text=temp.ToString();
else
privatevoidclear_Click(objectsender,EventArgse)//c清零
if(flag==1)
privatevoiddelete_Click(objectsender,EventArgse)//清零
#endregion
#region运算符
privatevoidequal_Click(objectsender,EventArgse)//等号
eq=1;
if(flag==1&
sp==0)
num2=Convert.ToDouble(this.numInput.Text);
this.txtInput.Text+=num2.ToString();
this.txtInput.Text+="
="
txtInput.Text=null;
switch(op)
case1:
result=num1+num2;
break;
case2:
result=num1-num2;
case3:
result=num1*num2;
case4:
result=num1/num2;
case5:
result=Math.Pow(num1,num2);
case6:
result=Mod(num1,num2);
default:
return;
if(op==4&
num2==0)
{
除数不能为0"
sp=1;
}else
//this.txtInput.Text+=result.ToString();
this.numInput.Text=result.ToString();
privatevoidsub_Click(objectsender,EventArgse)//减法
num1=Convert.ToDouble(this.numInput.Text);
this.txtInput.Text+=num1.ToString();
numInput.Text="
-"
op=2;
privatevoidmul_Click(objectsender,EventArgse)//乘法
*"
op=3;
privatevoiddivide_Click(objectsender,EventArgse)//除法
/"
op=4;
privatevoidplus_Click(objectsender,EventArgse)//加法
+"
op=1;
publicdoubleMod(doublex,doubley)//取模运算
inttemp=Convert.ToInt32(x/y);
return(x-y*temp);
privatevoidpower_Click(objectsender,EventArgse)//幂运算
num1=Convert.ToDouble(numInput.Text);
^"
op=5;
privatevoidrecip_Click(objectsender,EventArgse)//倒数
doubletemp=0;
temp=1/num1;
1/"
+num1.ToString()+"
privatevoidpercent_Click(objectsender,EventArgse)
//doubletemp=Convert.ToDouble(this.numInput.Text);
//this.txtInput.Text+=temp.ToString();
//temp=temp/100;
//this.numInput.Text=temp.ToString();
//this.txtInput.Text+="
%="
%"
op=6;
#endregion
#region数字
privatevoidone_Click(objectsender,EventArgse)//1
sp==0&
max==0)
if(this.numInput.Text=="
)
if(eq==1)
1"
eq=0;
this.numInput.Text+="
privatevoidtwo_Click(objectsender,EventArgse)//2
2"
privatevoidthree_Click(objectsender,EventArgse)//3
3"
privatevoidfour_Click(objectsender,EventArgse)//4
4"
//this.txtInput.Text+="
privatevoidfive_Click(objectsender,EventArgse)//5
5"
privatevoidsix_Click(objectsender,EventArgse)//6
6"
privatevoidseven_Click(objectsender,EventArgse)//7
7"
privatevoideight_Click(objectsender,EventArgse)//8
8"
privatevoidnight_Click(objectsender,EventArgse)//9
9"
privatevoidzero_Click(objectsender,EventArgse)//0
privatevoiddian_Click(objectsender,EventArgse)//小数点
."
#region三角函数
privatevoidsin_Click(objectsender,EventArgse)//sin
doubletemp=Math.PI*(num1/180);
sin("
+num1+"
)="
num1=Math.Sin(temp);
this.numInput.Text=num1.ToString();
//this.txtInput.Text+=num1.ToString();
privatevoidcos_Click(objectsender,EventArgse)//cos
cos("
num1=Math.Cos(temp);
privatevoidtan_Click(objectsender,EventArgse)//tan
tan("
num1=Math.Tan(temp);
#region帮助
privatevoid关于产品ToolStripMenuItem_Click(objectsender,EventArgse)
MenuAboutabout=newMenuAbout();
about.Show();
privatevoidchange_Click(objectsender,EventArgse)
sp==0)
num1=-num1;
privatevoid使用手册ToolStripMenuItem_Click(objectsender,EventArgse)
MenuUseuse=newMenuUse();
use.Show();
#region皮肤
privatevoid皮肤1ToolStripMenuItem_Click(objectsender,EventArgse)
skinEngine1.SkinFile=Application.StartupPath+@"
\Calmness.ssk"
privatevoid皮肤2ToolStripMenuItem_Click(objectsender,EventArgse)
\DeepCyan.ssk"
privatevoid皮肤3ToolStripMenuItem_Click(objectsender,EventArgse)
\Eighteen.ssk"
privatevoid皮肤4ToolStripMenuItem_Click(objectsender,EventArgse)
\GlassGreen.ssk"
privatevoid皮肤5ToolStripMenuItem_Click(objectsender,EventArgse)
\Silver.ssk"
#region复制粘贴
privatevoid复制ToolStripMenuItem_
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 编程 科学计算器 科学 计算器