给定一个年月值,返回上个年月值,格式为:YYYY.MM string类型
2016-02-23 16:48
477 查看
class Program { public string Lastmonth(string s ) { int a =int.Parse(s.Substring(0,4)); int b =int .Parse( s.Substring(4, 2)); if (b<=0||b>12 ) { return "请输入正确地月份"; } else if (b == 1) { a = a - 1; b = 12; return a.ToString() + b.ToString(); } else if (b == 12 || b == 11) { b = b - 1; return a.ToString() + b.ToString(); } else { b = b - 1; return a.ToString() +"0"+ b.ToString(); } } static void Main(string[] args) { Console.WriteLine("年月:"); string ss = Console.ReadLine(); Program pg = new Program(); Console.WriteLine( pg.Lastmonth(ss)); Console.ReadLine(); } }
相关文章推荐
- SSD+HDD 固态机械双硬盘 Ubuntu Win7 双系统
- 开发中遇到的小问题收集
- javascript瀑布流式图片懒加载实例解析与优化
- How to delete all the animations in a presentation
- mac 终端常见指令
- 学习linux计划书
- Using Android's tamper detection securely in your app
- hdu 1166 敌兵布阵(线段树,伸展树)
- 链表的反转
- cef3 经过GYP生成2010的工程文件后还是有问题
- iOS开发在popView的时候出现错误
- WEB常用攻击手段以及解决办法脑图
- Giraph++ 系统配置过程
- ehcache的使用
- mysql 行转列
- Jmeter中正则表达式提取器使用详解
- Android--向SD卡读写数据
- @Transient----------------springMVC
- cmd和python的mysql连接方法
- iOS9网络适配_改用更安全的HTTPS