编程介的小学生 2019-04-21 14:01 采纳率: 20.5%
浏览 496

判断字符串消息是否符合特定的规则,用C程序的语言的实现的办法和过程怎么做?

Problem Description
Mr. Manners teaches netiquette ("net etiquette", particularly as it applies to email) at the local community college. There are many different aspects to proper netiquette, including courtesy, correct spelling, and correct grammar. Through experience Mr. Manners has found that his college's email system does a good job of catching most spelling and grammatical errors, and he's also found that most of his students are courteous. So there are four violations of netiquette that Mr. Manners pays careful attention to, and he's devised a quick way to test for them. A message is suspicious if it contains any of the following:
1. two adjacent uppercase letters,
(because you might be SHOUTING)
2. a digit adjacent to a letter,
(because you might be l33t, d00d)
3. an isolated character other than a, A, or I,
(because u r probably abbreviating words; the spell checker doesn't catch this for some reason)
4. two adjacent punctuation marks, unless one of them is a double quote (the character ").
(because you might be using an emoticon :-)
For this problem, all characters in an email message are printable ASCII characters with codes in the range 32..126 (inclusive). A punctuation mark is any character other than a letter, digit, or space. Two characters are adjacent if they are right next to each other, with no characters in between. An isolated character is one whose only adjacent characters (if any) are spaces. Your job is to write a program that can tell if a one-line email message is suspicious.

Input
The input consists of one or more email messages, followed by a line containing only # that signals the end of the input. Each message is on a line by itself, does not begin or end with a space, and does not contain consecutive spaces. End-of-line characters occur at the end of every line (of course), but they are not considered to be part of the message. A message will contain 1..80 characters.

Output
For each message, output suspicious if it meets one or more of the four criteria defined above, and output OK otherwise. In the examples below, the second email meets all four criteria, and the fourth and sixth emails meet one criterion each.

Sample Input
"This is a safe message," said 50 wise men.
DON'T b l8 for the Apple ][ user's group meeting.
I ate at "Al's Big Burritos" for lunch!
It's not OK to burp at your grandmother.
BuT YoU CaN Do ThIs, YoU KnOw.
We 8 eight oranges.
#

Sample Output
OK
suspicious
OK
suspicious
OK
suspicious

  • 写回答

1条回答 默认 最新

  • qq_41043532 2019-04-21 14:27
    关注

    #include
    #include
    #include
    先导入库

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料