.net(三个简单的作业)
来源:互联网 发布:网络霸凌 社交平台 编辑:程序博客网 时间:2024/05/22 01:30
1,读入一个小数,将小数部分和整数部分交换:例如 3.14 ---〉14.3
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace TestExchange{ class Program { static void Main(string[] args) { while (true) { // 1,从控制台读入一个小数,存放在 testDouble 中 string testDouble = Console.ReadLine(); // 2,转为double 类型 double result; // 用try ... catch ... 语句捕获格式错误的异常 try { result = double.Parse(testDouble); // 3,将testDouble以‘.’隔开 string[] splitStr = testDouble.Split('.'); // 4,格式输出 Console.WriteLine("{0}.{1}", int.Parse(splitStr[1]), int.Parse(splitStr[0])); } catch (FormatException e) { // 捕获数字格式不正确的异常 Console.WriteLine("输入数字格式不正确"); } catch (System.IndexOutOfRangeException e) { // 捕获全部整数不包含小数点的异常 Console.WriteLine("输入的数应包含小数点"); } } } }}
2,定义一个qq状态的枚举(在线、隐身、离线…)。
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace TestQQState{ class Program { static void Main(string[] args) { } } // 定义QQ状态的枚举 enum QQState { OnLine, //在线 OffLine, //离线 Hidding, //隐身 Busy //忙碌 }}
3, 老婆给当程序员的老公打电话:“下班顺路买10个包子,如果看到卖西瓜的,买一个。”下班后,老公买回一个包子,因为他看到卖西瓜的了,老婆气晕了。分别用程序表达这句话的意思:老婆的意思;程序员老公理解的意思。
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace TestJok{ class Program { static void Main(string[] args) { Husband husband = new Husband(); // 买包子的个数 int bzCount; // 买西瓜的个数 int xgCount; // 是不是有买西瓜的 bool isThereHasXiGua = false; // 老婆的意思 husband.getOffWork(); // 老公下班 husband.buyBaozi(10); // 老公买十个包子 if (isThereHasXiGua == true) // 如果看到卖西瓜的 { husband.buyXiGua(1); // 买一个西瓜 } //老公的意思 husband.getOffWork(); // 老公下班 if (isThereHasXiGua == false) // 如果没有看到买西瓜的 { husband.buyBaozi(10); // 买 10 个包子 } else // 如果看到卖西瓜的 { husband.buyBaozi(1); // 买 1 个包子 } } } /// <summary> /// Husband 类 /// </summary> class Husband { /// <summary> /// 买包子的方法 /// </summary> /// <param name="bzCount">买的包子的个数</param> public void buyBaozi(int bzCount) { } /// <summary> /// 下班的方法 /// </summary> public void getOffWork() { } /// <summary> /// 买西瓜的方法 /// </summary> /// <param name="xgCount">买的西瓜的个数</param> public void buyXiGua(int xgCount) { } }}
- .net(三个简单的作业)
- 简单的.NET三层框架的实现(学生作业管理系统)
- 定时作业框架Quartz.net的简单应用
- Hadoop for .NET Developers(十二):实现简单的MapReduce作业
- 作业02: 实现三个数值的转换。
- 类模板的简单例子(作业)
- Java的三个简单特性
- 三个简单的排序方法
- .net定时任务(作业)-简单说
- ADO.NET 主要的三个对象(SqlConnection/SqlCommand/SqlDataReader)
- BFS专攻:POJ 3278 (三个方向的简单BFS)
- VB作业之比较三个数的大小
- 栈的作业:简单计算器
- 简单的假期作业√
- JAVA作业 简单的计算器
- 三个简单的n方的排序
- 三个.net做安装程序的步骤
- VisualStudio.Net三个版本的区别
- error: ‘::WSAGetLastError’ has not been declared
- .net(关于字符串的相等问题[比较重要])
- 基于Delphi的融合DLL中的窗口
- 2012财富世界500强发布,大陆首超日本,新增12家
- MIPS汇编指令
- .net(三个简单的作业)
- ubuntu grub 启动项恢复
- sql 插入含有主键的列,提示:你没有该列的权限限制的解决方法
- Hex文件格式解析
- BFS的基本模版
- HDU 4007
- 如何用美剧真正提升你的英语水平
- 解决电脑常见问题
- class wizard不显示控件ID的问题及解决办法