帮我解决这个C ++问题 [英] Help me to solve this C++ problem

查看:59
本文介绍了帮我解决这个C ++问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题


小国的道路和交通管理部门目前使用

系统来存储所有当前许可​​驾驶员的信息。


许可的驱动程序在

记录中存储有关于它们的以下信息;

1.给出的名称许可证持有人。(不超过128个字符(可能

有空格))。

2.许可证持有人的姓氏。(不超过128,如上所述) 。

3.驾驶执照号码。

4.执照持有人的性别。

5.执照持有人的住址。 (不多于

128)相同。

6.许可证持有人驾驶的汽车的注册号码。(A / $
char组合字符串必须长六个。)


当前系统允许用户添加新的许可证持有者,修改

有关现有许可证持有者的详细信息并删除许可证持有人

进入许可证se number。


你的工作是编写一个C ++程序来替换已有的系统。

这样做你的程序必须;


1.允许用户在系统中添加新的许可证持有者。

2.允许用户从系统中删除许可证持有者。

3.允许用户搜索许可证号码,显示和

可能修改匹配的记录。


该程序是一个交互式菜单驱动程序。用户可以从

中选择一组选项来执行特定操作。它还有

持久存储。每个许可证持有者在系统中都有一条记录。

记录一个固定的长度,因此不能使用C ++类型的字符串
实施中
。程序第一次运行时,文件系统中没有

数据文件。该文件是一个randoom访问文件,使用

存储有关liccense持有者的记录集合。这个文件的名称是

这个文件是data.dat。


如果文件在程序启动时已经存在,你就要阅读

将文件中的所有记录转换为记录数组。您可以假设

阵列的最大大小为500.即在任何给定时间,您的
系统最多可容纳500个许可证持有者。


在运行期间,用户可以添加新的许可证记录。当用户添加一个

的新记录时,程序会提示用户输入所有相关的详细信息

到记录。该记录被插入到记录数组中的第一个可用插槽中,并立即写入

相应记录位置的文件。如果没有可用记录,则打印

错误。


当用户删除记录时,记录的所有元素都被清除

并且记录被标记为可用。然后将

文件中的相应记录标记为可用。


用户可以搜索/显示/修改记录。搜索键是

许可证号。如果某个记录的许可证编号与指定的密钥匹配,则会显示该记录,并且用户可以选择修改记录的

选项。用户可以搜索记录并显示它而不进行任何修改。


您的程序应执行相应的检查以确保有效

随时输入。

解决方案



" titi" < WW **** @ yahoo.com>在消息中写道

news:bf ************************** @ posting.google.c om ...

问题

一个小国家的道路和交通管理部门目前使用
系统存储有关所有当前许可​​驱动程序的信息。



< SNIP>


请不要发布作业问题。

http://www.parashift.com/c++- faq-lit ... t.html#faq-5.2


问候,

Sumit。

< br>

2004年2月8日06:51:41 -0800
ww **** @ yahoo.com (titi)写道:


您是否在发布之前阅读了该问题?具体来说:

你的工作是编写一个C ++程序来替换已有的系统。



^^^^


如果您对* your *程序有特定问题,请发布

最小的可编译代码片段,以确定您遇到问题

,随着输入,预期输出和实际输出你得到了b $ b。我们不做这里的作业!


问候,


马特。


< blockquote> titi写道:

一个小国家的道路和交通管理部门目前使用
系统存储有关所有当前许可​​驱动程序的信息。


< snip>


这需要一些时间。我认为初学者的一个常见错误是

试图做到这一点正确。在第一次尝试。这导致很多打字,很多语法错误,以及对最终被抛弃的事物细节的大量烦恼;结果浪费了大量的时间。 (例如关于检查有效数据的警告。)我将

仅从最小的数据字段子集开始。姓氏,简单的一部分

名称如史密斯(与冯诺伊曼不同)和许可证号码可能

就足够了。 BTW关于旧的现有程序的事情似乎主要是

噪音让你迷惑。获得简单的工作来建立信心

路径和方法将起作用,然后开始用

详细信息来充实它。请注意,当女人结婚时,姓氏可能会改变。我看到一个

菜单,一个用于保存数据的类以及这些类的普通数组

* main *。请注意,C ++通常默认与你期望的相反

WRT空格。


这个程序将是90%的批量和10%有用和有趣的东西。


Question

The road and traffic authority for a small country currently uses a
system to store information about all ''currently'' licensed drivers.

A licensed driver has the following info stored about them in a
record;
1. Given name(s) of the license holder.(not more than 128 char (may
have spaces)).
2. Surname of the license holder.(Not more then 128 same like above).
3. Driver license number.
4. The sex of the license holder.
5. The residental address of the license holder.(Not more then
128)same.
6. The registration number of the car the license holder drivers.(A
combination of char and numbers. The string must be six long.)

The current system allow users to add new license holders, modify
details about prexisting license holders and remove a license holder
by entering the license number.

Your job is to write a C++ program to replace the pre-existing system.
In doing so your program must;

1.Allow user to add new license holders to the system.
2.Allow user to remove the license holder from the system.
3. Allow the users to search on a license number, display and
potentially modify a matched record.

The program is an interactive and menu driven. A user can choose from
a set of options to perform a particular action. It also to has
persistent storage.Each license holder has one record in the system.
Records a fixed lenght, therefore the C++ type string cannot be used
in the implementation. The first time the program is run, there is no
data file in the file system. The file is a randoom access file used
to store a collection of records about liccense holders. The name of
this file is data.dat.

If the file already exists when the program starts, you are to read
the all records from the file, into array of records. You can assume
the maximum size of the array is 500. That is at any given time, your
system can hold a maximum of 500 license holders.

During runtime a user may add new license records.When a user adds a
new record, the program prompt the user to enter all details relevent
to the record. The record is inserted into the first available slot in
the array of records and written to the file immediately at the
correseponding record location. If there are no available records an
error is to be printed.

When a user removes a record, all elements of the record are cleared
and the record is marked as available. The corresponding record in the
file is then marked available.

Users can search/dispaly/modify a record. The search key is the
license number. If there is a record with the license number matching
the specified key, the record is displayed and the user given the
option of modifying the record. A user can search for a record and
display it without performing any modifications.

Your program should perform the appropriate checks to ensure valid
input at ALL time.

解决方案


"titi" <ww****@yahoo.com> wrote in message
news:bf**************************@posting.google.c om...

Question

The road and traffic authority for a small country currently uses a
system to store information about all ''currently'' licensed drivers.



<SNIP>

Please do not post homework questions.

http://www.parashift.com/c++-faq-lit...t.html#faq-5.2

Regards,
Sumit.


On 8 Feb 2004 06:51:41 -0800
ww****@yahoo.com (titi) wrote:

Did you read the question before you posted it? Specifically:

Your job is to write a C++ program to replace the pre-existing system.


^^^^

When you have a specific problem with *your* program then post the
smallest relevant snippet of compilable code that you''re having problems
with, along with the input, expected output and actual output you''re
getting. We don''t do homework here!

Regards,

Matt.


titi writes:

The road and traffic authority for a small country currently uses a
system to store information about all ''currently'' licensed drivers.


<snip>

This is going to take some time. I think a common mistake of beginners is
trying to do it "right" in the first attempt. This results in a lot of
typing, a lot of syntax errors, and a lot of fussing over details of things
that eventually get thrown away; with the result of wasting huge amounts of
time. (For example the warning about checking for valid data.) I would
start with only a minimal subset of data fields. Last name, simple one part
name such as Smith (as distinct from von Neuman) and license number might
be enough. BTW the thing about the old existing program seems to be mainly
noise to confuse you. Get the simple thing working to establish confidence
that the paths and methods will work, then start fleshing it out with
details. Note that a surname can change when a woman marries. I see a
menu, a class to hold the data and an ordinary array of these classes in
*main*. Note that C++ often defaults to do the opposite of what you expect
WRT white space.

This program is going to be 90% bulk and 10% useful and interesting "stuff".


这篇关于帮我解决这个C ++问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆