给定一个年月值,返回上个年月值,格式为:YYYY.MM string类型
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(); } }