struct Date { year: u16, month: u8, day: u8, } impl Date { #[allow(dead_code)] fn is_leap_year(&self) -> bool { let y = self.year; (y % 4 == 0) ^ (y % 100 == 0) ^ (y % 400 == 0) } #[allow(dead_code)] fn get_month_lastday(&self) -> u8 { match self.month { 4|6|9|11 => 30, 2 => match self.is_leap_year() { true => 29, _ => 28, }, _ => 31, } } #[allow(dead_code)] fn increase_year(&mut self) { self.year = self.year + 1; } #[allow(dead_code)] fn increase_month(&mut self) { self.month = match self.month { 12 => { self.increase_year(); 1 }, _ => self.month + 1, }; } #[allow(dead_code)] fn increase_day(&mut self) { if self.day == self.get_month_lastday() { self.increase_month(); self.day = 1; } else { self.day += 1; } } #[allow(dead_code)] fn show(&self) { println!("{0:>04}/{1:>02}/{2:>02}", self.year, self.month, self.day); } } use std::io; fn main(){ let mut input = String::new(); io::stdin().read_line(&mut input).ok(); let mut v = input.trim().split("/"); let y: u16 = v.next().unwrap().parse().unwrap(); let m: u8 = v.next().unwrap().parse().unwrap(); let d: u8 = v.next().unwrap().parse().unwrap(); let mut d = Date {year:y, month:m, day:d}; d.increase_day(); d.increase_day(); d.show(); }