联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codehelp

您当前位置:首页 >> Python程序Python程序

日期:2021-03-05 08:37

Once again, COVID-19 plaque is out of control and the anti pandemic measures must be more restrictive. This time, there is a need to better track the contacts. The government is granted an access to each citizen’s mobile and its phone book. Your task is to develop a program to simplify the search in such phone books.
The required function is:
bool report ( const string & fileName, ostream & out );
?fileName?is a string with the file name of the phone book to analyze,
?out?is an output stream to write the report to,
?return value is?true?(all processing was OK) or?false?if there was an error.
The input file is a text file with a list of contacts, an empty line, and a list of searches. Each contact is placed on a single line, the contact consist of a name, surname, and a phone number. The fields are separated by any number of white characters (newline is not used to separate the fields). The searches are formed by a list of names (words) to search for.
Your function finds the records where the name, surname, or both matches the searched string. The strings must match completely, i.e., “Joh” and “John” do not match. The matched records must be printed to the?out?stream, moreover, the order of records must be preserved. Do not send any output to?cout?or?cerr.
The input / output format is clear from the attached examples. If the input is invalid, return?false. The following is considered an error:
?a field is missing,
?a phone number is not exactly 9 digits long,
?there is a non-digit character in a phone number,
?a phone number starts with 0,
?there are some extraneous characters following the phone number (white space is fine),
?the empty line separator is missing.

版权所有:留学生编程辅导网 2021,All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。