1 / 1

Programming Test 2

Programming Test 2. 学号检验 小明所在的学校,每个学生都有一个学号。学号的编码有以下规律: 1) 学号的编码长度是 9 ; 2) 学号第一个字符是字母 ’ b ’ 或者 ’ g ’ , 大小写均可; 3) 学号的第 2-5 位表示入学年份 , 入学年份在 2003-2009 之间 ( 包括 2003 , 2009) ; 4) 学号的第 6-9 位是任意数字 (0-9) 。下面请编写一个程序,判断是否可能是小明所在学校的学号编码。若是请输出 YES ,若不是请 NO 。 输入:一个长度不超过 15 的字符串 输出: YES/NO

Download Presentation

Programming Test 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Test 2 学号检验 • 小明所在的学校,每个学生都有一个学号。学号的编码有以下规律: • 1) 学号的编码长度是9; • 2) 学号第一个字符是字母’b’或者’g’,大小写均可; • 3) 学号的第2-5位表示入学年份,入学年份在2003-2009之间(包括2003,2009); • 4) 学号的第6-9位是任意数字(0-9)。下面请编写一个程序,判断是否可能是小明所在学校的学号编码。若是请输出YES,若不是请 NO。 • 输入:一个长度不超过15的字符串 • 输出:YES/NO • 例如:输入:B20041a20 输出: NO • 测试用例 1)输入:B20041a20 3)输入:G20041220 5)输入:120041220 输出:NO 输出:YES 输出:NO 2)输入:B200412200 4)输入:g20041220 6)输入:G20021220 输出:NO 输出:YES 输出:NO

More Related