c# winform 程序实现 复数基本运算
来源:互联网 发布:java 内存泄漏检测工具 编辑:程序博客网 时间:2024/05/16 17:28
不多废话,直接源代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Complex
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox_operation.SelectedIndex = 0;
}
private void button_calc_Click(object sender, EventArgs e)
{
int real1 = 0, real2 = 0;
int image1 = 0, image2 = 0;
string opera="";
try
{
real1 = Convert.ToInt32(this.textBox_real1.Text);
image1 = Convert.ToInt32(this.textBox_image1.Text);
real2 = Convert.ToInt32(this.textBox_real2.Text);
image2 = Convert.ToInt32(this.textBox_image2.Text);
opera = Convert.ToString(this.comboBox_operation.SelectedItem);
}
catch
{
MessageBox.Show("请输入正确形式的数据!", "错误提示");
}
switch (opera)
{
case "+":
this.textBox_result.Text = (real1 + real2) + ((image1 + image2) >= 0 ? "+" + (image1 + image2) + "i" : (image1 + image2) + "i");
break;
case "-":
this.textBox_result.Text = (real1 - real2) + ((image1 - image2) >= 0 ? "+" + (image1 - image2) + "i" : (image1 - image2) + "i");
break;
case "*":
this.textBox_result.Text = (real1 * real2 - image1 * image2) + ((real1 * image2 + real2 * image1) >= 0 ? "+" + (real1 * image2 + real2 * image1) + "i" : (real1 * image2 + real2 * image1) + "i");
break;
}
}
}
}
程序运行结果:
- c# winform 程序实现 复数基本运算
- C# 实现 复数 运算 类
- 类模板实现复数运算的基本操作
- Python实现复数运算
- C# WinForm 如何实现程序重启?
- C# -- 实现WinForm程序的密码修改
- 友元实现复数运算
- c++实现复数类运算
- 通过运算符重载实现复数运算
- C#小程序1--复数
- (1)基本运算+复数+字符串
- C#开发WinForm程序如何实现程序最小化到系统托盘
- 复数类[一]----C#实现
- c# winForm 发布程序
- c# winform 关机程序
- c# winform 关机程序
- 编写一个类实现复数的运算
- 实现复数的一般算术运算
- 一个在MFC下使用的简单等待对话框类
- New Year, New Life
- 写给新手程序员的一封信
- android知识链接汇总
- 码斗士的修炼之路 -- 如何保持并提升战斗力
- c# winform 程序实现 复数基本运算
- VS2010 RDLC 横向合并时“未正确设置 tablix“Tablix1”的 FixedData 属性”错误解决方法
- 中药秘方——留着有用
- qmake简介
- c语言 读取当前时间
- 第一篇博文
- java.lang.NoSuchMethodError: net.sf.cglib.proxy.Enhancer.setInterceptDuringConstruction(Z)V
- String.IndexOf 方法
- c#访问器使用举例 (长方体)