Importation du code depuis GitHub
這個提交存在於:
當前提交
944682212c
共有 140 個檔案被更改,包括 3014012 行新增 和 0 行删除
674
License
一般檔案
674
License
一般檔案
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
二進制
autres/monty_hall/monty_hall
可執行檔
二進制
autres/monty_hall/monty_hall
可執行檔
未顯示二進位檔案。
106
autres/monty_hall/monty_hall.adb
一般檔案
106
autres/monty_hall/monty_hall.adb
一般檔案
|
@ -0,0 +1,106 @@
|
|||
with Ada.Text_Io;
|
||||
with Ada.Numerics.Discrete_Random;
|
||||
with Ada.Command_Line;
|
||||
|
||||
use Ada.Command_Line;
|
||||
use Ada.Text_Io;
|
||||
|
||||
procedure Monty_Hall is
|
||||
|
||||
subtype Ternary is Integer range 1..3;
|
||||
|
||||
package Random_bool is new Ada.Numerics.Discrete_Random(Boolean);
|
||||
package Random_Ternary is new Ada.Numerics.Discrete_Random(Ternary);
|
||||
|
||||
package RB renames Random_Bool;
|
||||
package RT renames Random_Ternary;
|
||||
|
||||
HasardRB : RB.Generator;
|
||||
HasardRT : RT.Generator;
|
||||
|
||||
|
||||
type Door is record
|
||||
Name : String;
|
||||
Is_Open : Boolean;
|
||||
Hide_Goat : Boolean;
|
||||
end record;
|
||||
|
||||
type List_D is array (Integer range <>) of Door;
|
||||
|
||||
type Strat is (C,N,R); -- Change / Not_Change / Random
|
||||
|
||||
--Initialisation des portes
|
||||
procedure Set_Door (A,B,C : out Door) is
|
||||
T : Ternary;
|
||||
begin
|
||||
A := ("A",False, False);
|
||||
B := ("B",False, False);
|
||||
C := ("C",False, False);
|
||||
|
||||
T := RT.Random(HasardRT);
|
||||
case T is
|
||||
when 1 => A.Hide_Goat := True;
|
||||
when 2 => B.Hide_Goat := True;
|
||||
when 3 => C.Hide_Goat := True;
|
||||
end case;
|
||||
end Set_Door;
|
||||
|
||||
-- Le présentateur désigne une porte dans la liste
|
||||
function Presentateur(L : in List_D(1..2)) return Integer is
|
||||
I : Integer;
|
||||
begin
|
||||
if List_D(1).Hide_Goat and List_D(2).Hide_Goat then
|
||||
I := RB.Random(HasardRB);
|
||||
elsif List_D(1).Hide_Goat and not List_D(2).Hide_Goat then
|
||||
I := 1;
|
||||
else
|
||||
I := 2;
|
||||
end if;
|
||||
return I;
|
||||
end Presentateur;
|
||||
|
||||
|
||||
--Joue 1 jeu, retourne vrai si le joueur gagne
|
||||
function Game (S : in Strat) return Boolean is
|
||||
A, B, C, M : Door; -- M buffer
|
||||
Choice_T1 : Door;
|
||||
L1 : List_D(1..3) := (A,B,C);
|
||||
L2 : List-D(1..2);
|
||||
begin
|
||||
Set_Door(A,B,C);
|
||||
|
||||
-- Tour 1 et liste des porte restantes
|
||||
case RT.Random(HasardRT) is
|
||||
when 1 => Choice_T1 := A; L2 := (B,C); M := A;
|
||||
when 2 => Choice_T1 := B; L2 := (A,C); M := B;
|
||||
when 3 => Choice_T1 := C; L2 := (A,B); M := C;
|
||||
end case;
|
||||
--Fin Tour 1
|
||||
|
||||
-- Action Présentateur
|
||||
L2(Presentateur(L2)).IS_Open := True;
|
||||
L1 := ((M) & L2);
|
||||
|
||||
for J in L1'Range loop
|
||||
if L1(J).IS_Open then
|
||||
Put_Line("Porte " & L1(J).Name & " ouverte" );
|
||||
elsif
|
||||
|
||||
end if;
|
||||
end loop;
|
||||
--##
|
||||
--## ALGORITHME NON FINI
|
||||
--##
|
||||
--##
|
||||
return A.Hide_Goat;
|
||||
end Game;
|
||||
|
||||
|
||||
begin
|
||||
RB.Reset(HasardRB);
|
||||
RT.Reset(HasardRT);
|
||||
|
||||
if Game then
|
||||
Put("OK");
|
||||
end if;
|
||||
end Monty_Hall;
|
4236
autres/nb_premiers/list.txt
一般檔案
4236
autres/nb_premiers/list.txt
一般檔案
檔案差異因為檔案過大而被隱藏
載入差異
二進制
autres/nb_premiers/nb_premiers
可執行檔
二進制
autres/nb_premiers/nb_premiers
可執行檔
未顯示二進位檔案。
|
@ -0,0 +1,93 @@
|
|||
with Ada.Text_Io;
|
||||
use Ada.Text_Io;
|
||||
|
||||
with Ada.Numerics.Elementary_Functions;
|
||||
use Ada.Numerics.Elementary_Functions;
|
||||
|
||||
procedure Nb_Premiers is
|
||||
|
||||
-- Variables parametres
|
||||
subtype SIZE is Integer range 1..18;
|
||||
|
||||
|
||||
-- Fonction de test de nb premiers
|
||||
function Is_Prime(N : Long_Integer) return Boolean is
|
||||
Prime : Boolean := True;
|
||||
begin
|
||||
if N mod Long_Integer(2) = 0 and N /= 2 then
|
||||
Prime := False;
|
||||
else
|
||||
for I in 2..(Long_Integer(1.0+Sqrt(Float(N)))/2) loop
|
||||
if N mod Long_Integer(2*I-1) = 0 then
|
||||
Prime := False;
|
||||
exit;
|
||||
end if;
|
||||
end loop;
|
||||
end if;
|
||||
return prime;
|
||||
end Is_Prime;
|
||||
|
||||
-- Affichage nombre premier
|
||||
procedure IP(N : Long_Integer) is
|
||||
begin
|
||||
if Is_Prime(N) then
|
||||
Put_Line(Long_Integer'Image(N) & " premier");
|
||||
else
|
||||
Put_Line(Long_Integer'Image(N) & " n'est pas premier");
|
||||
end if;
|
||||
end IP;
|
||||
|
||||
-- Afficher les nb troncables d'une certaine taille
|
||||
procedure Aff_Troncable(N : Long_Integer) is
|
||||
--T_Min : constant Natural := 1; --Nombre de digits des nombres affichés
|
||||
begin
|
||||
Put_Line(Long_Integer'Image(N));
|
||||
end Aff_Troncable;
|
||||
|
||||
|
||||
-- Puissance de 10
|
||||
function mode(M : Long_Integer) return Long_Integer is
|
||||
I : Long_Integer := 0;
|
||||
N : Long_Integer := M;
|
||||
begin
|
||||
while N >= 0 loop
|
||||
N := N - 10**(Integer(I));
|
||||
I := I + 1;
|
||||
end loop;
|
||||
return I;
|
||||
end mode;
|
||||
|
||||
|
||||
-- Recherche de nombres premiers tromcables
|
||||
procedure Troncable(N : Long_Integer) is
|
||||
N3 : Long_Integer := 0;
|
||||
begin
|
||||
if Is_Prime(N) then
|
||||
Aff_Troncable(N);
|
||||
if N < (Long_Integer'Last / 100) then
|
||||
for I in 1..9 loop
|
||||
N3 := 10;
|
||||
for J in 1..(Mode(N) - 2) loop
|
||||
N3 := N3 * 10;
|
||||
end loop;
|
||||
Troncable(N + Long_Integer(I)*N3);
|
||||
end loop;
|
||||
elsif N < (Long_Integer'Last / 11) then
|
||||
for I in 1..8 loop
|
||||
N3 := 10;
|
||||
for J in 1..(Mode(N) - 2) loop
|
||||
N3 := N3 * 10;
|
||||
end loop;
|
||||
Troncable(N + Long_Integer(I)*N3);
|
||||
end loop;
|
||||
end if;
|
||||
end if;
|
||||
end Troncable;
|
||||
|
||||
|
||||
begin
|
||||
Troncable(Long_Integer(2));
|
||||
Troncable(Long_Integer(3));
|
||||
Troncable(Long_Integer(5));
|
||||
Troncable(Long_Integer(7));
|
||||
end Nb_Premiers;
|
31
readme.md
一般檔案
31
readme.md
一般檔案
|
@ -0,0 +1,31 @@
|
|||
# cours_ada
|
||||
Partage de mes essais en Ada dans le cadre des cours de 2ème année MIC à l'INSA Toulouse et du [cours d'openclassroom](https://openclassrooms.com/fr/courses/900279-apprenez-a-programmer-avec-ada).
|
||||
Le code est sous licence GNU GPL 3, les cours de l'INSA et d'openclassroom appartiennent à leurs propriétaires respectifs.
|
||||
|
||||
### Index - Cours INSA du semestre 4
|
||||
* TD1 : Pointeurs et listes :
|
||||
* semestre4/listes
|
||||
* semestre4/listes_doulement_chaine
|
||||
* TD2 : Paquetages :
|
||||
* semestre4/paquetages
|
||||
* TD3 : Généricité :
|
||||
* semestre4/listes_ordonnees
|
||||
* TD4 : Arbres binaires
|
||||
* semestre4/arbres_binaires
|
||||
|
||||
* TP1 : Piles et expressions postfixées
|
||||
* semestre4/TP1_piles
|
||||
* TP2 : Paquetages de listes ordonnées d'entiers, type privé & limité privé
|
||||
* semestre4/TP2_listes_ordonnees_type_LP
|
||||
* TP3 : Paquetages génériques
|
||||
* semestre4/TP3_paquetages_generiques
|
||||
* TP4 : Arbres binaires et paquetages génériques
|
||||
* semestre4/TP4_arbres_binaires_genericite
|
||||
* TP5 : Tri par tas
|
||||
* semestre4/TP5_tri_par_tas
|
||||
* Correction CC1 : Files / LIFO
|
||||
* semestre4/cc1
|
||||
|
||||
### Travaux divers
|
||||
(Obsolète) Partage de quelques travaux personnels, voir [travaux.md](travaux.md).
|
||||
|
二進制
semestre3/Kaprekar/main
可執行檔
二進制
semestre3/Kaprekar/main
可執行檔
未顯示二進位檔案。
204
semestre3/Kaprekar/main.adb
一般檔案
204
semestre3/Kaprekar/main.adb
一般檔案
|
@ -0,0 +1,204 @@
|
|||
with ada.Text_IO, Ada.Integer_Text_IO;
|
||||
with ada.Calendar;
|
||||
|
||||
use ada.Text_IO;
|
||||
|
||||
procedure Main is
|
||||
|
||||
-- Type & package
|
||||
subtype chiffre is Natural range 0..9;
|
||||
type nbr is array (Integer range <>) of Integer;
|
||||
package date renames ada.Calendar;
|
||||
|
||||
|
||||
-- Variables globales
|
||||
FND : constant Integer := 100; -- FIND
|
||||
WST : constant Integer := FND - 1; -- WRITE START
|
||||
|
||||
|
||||
data_dect : nbr(1..FND);
|
||||
-- Ce tableau contient des nombres pour de la detection de boucle
|
||||
-- Le rang WST et FND sont des rangs de services
|
||||
|
||||
|
||||
-- Procédure de detection de boucle, utilise la base de données data_dect
|
||||
procedure detect_loop (int : in Integer) is
|
||||
debut_ecriture : Integer := data_dect(WST);
|
||||
begin
|
||||
for i in data_dect'First..(WST - 1) loop
|
||||
if int = data_dect(i) then
|
||||
data_dect(FND) := 1;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
data_dect(debut_ecriture) := int;
|
||||
data_dect(WST) := data_dect(WST) + 1;
|
||||
|
||||
if data_dect(WST) >= WST then
|
||||
raise Storage_Error;
|
||||
end if;
|
||||
|
||||
end detect_loop;
|
||||
|
||||
|
||||
-- Tri par ordre croissant un tableau d'integer
|
||||
procedure tri (tab : in out nbr) is
|
||||
buffer : nbr(tab'Range);
|
||||
valeur : Integer := 0;
|
||||
pos : Integer := 0;
|
||||
begin
|
||||
for k in tab'Range loop
|
||||
valeur := 0;
|
||||
pos := tab'last;
|
||||
for i in tab'range loop
|
||||
if tab(i) >= valeur then
|
||||
pos := i;
|
||||
valeur := tab(i);
|
||||
end if;
|
||||
end loop;
|
||||
tab(pos):=0;
|
||||
buffer(k) := valeur;
|
||||
end loop;
|
||||
tab := buffer;
|
||||
end tri;
|
||||
|
||||
|
||||
-- Tri par ordre décroissant
|
||||
procedure tri_inverse (tab : in out nbr) is
|
||||
buffer : nbr(tab'Range);
|
||||
begin
|
||||
tri(tab);
|
||||
for i in tab'range loop
|
||||
buffer(i):=tab(tab'last-(i-1));
|
||||
end loop;
|
||||
tab:=buffer;
|
||||
end tri_inverse;
|
||||
|
||||
-- Partie opérative de l'algo de Kaprekar (nombre en deux tableaux triés, affiche et retourne la différence des nombres
|
||||
function operation (nombre : integer; dimension : Integer) return Integer is
|
||||
ord_croiss : nbr(1..dimension);
|
||||
ord_droiss : nbr(1..dimension);
|
||||
nombre_croiss : Integer := 0;
|
||||
nombre_droiss : Integer := 0;
|
||||
nombre_stock : Integer := nombre;
|
||||
begin
|
||||
-- On met le nombre dans un tableau
|
||||
for k in 1..dimension loop
|
||||
ord_croiss(k) := (nombre_stock/10**(dimension-(k)));
|
||||
nombre_stock := nombre_stock - ord_croiss(k)*10**(dimension-k);
|
||||
end loop;
|
||||
|
||||
--tri
|
||||
ord_droiss := ord_croiss;
|
||||
tri(ord_croiss);
|
||||
tri_inverse(ord_droiss);
|
||||
|
||||
for j in 1..dimension loop
|
||||
nombre_droiss := nombre_droiss + ord_droiss(j) * (10**(dimension - (j)));
|
||||
nombre_croiss := nombre_croiss + ord_croiss(j) * 10**(dimension -(j));
|
||||
|
||||
end loop;
|
||||
|
||||
Put_Line("N1 = " & Integer'Image(nombre_croiss) & " N2 = " & Integer'Image(nombre_droiss) & " N1 - N2 = " & Integer'Image(nombre_croiss - nombre_droiss));
|
||||
|
||||
return nombre_croiss - nombre_droiss;
|
||||
end operation;
|
||||
|
||||
|
||||
-- Permet de déterminer la taille d'un nombre
|
||||
function nb_digits (nombre : Integer) return Integer is
|
||||
dimension_nok : Boolean := true;
|
||||
dimension : Integer := 0;
|
||||
i : Integer := 0;
|
||||
begin
|
||||
while dimension_nok loop
|
||||
if (nombre / 10**i) <= 0 then
|
||||
dimension_nok := false;
|
||||
dimension := i;
|
||||
else
|
||||
i := i + 1;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
if dimension = 0 then
|
||||
dimension := 1;
|
||||
end if;
|
||||
|
||||
return dimension;
|
||||
end nb_digits;
|
||||
|
||||
|
||||
-- Procédure de coordination des fonctions de l'algorithme et de la detection de boucle
|
||||
procedure kaprekar (nombre : in out Integer) is
|
||||
dimension_nok : Boolean := true;
|
||||
dimension : Integer := 0;
|
||||
i : Integer := 0;
|
||||
temp : Integer := nombre;
|
||||
begin
|
||||
nombre := temp + 1;
|
||||
|
||||
while nombre /=temp loop
|
||||
dimension := nb_digits(temp);
|
||||
nombre := temp;
|
||||
temp := operation(temp, dimension);
|
||||
|
||||
detect_loop(temp);
|
||||
if data_dect(FND) = 1 then
|
||||
Put_Line("Boucle dans l'algorithme");
|
||||
nombre := temp;
|
||||
end if;
|
||||
|
||||
|
||||
delay 0.2;
|
||||
Put_Line("--------------");
|
||||
end loop;
|
||||
|
||||
|
||||
end kaprekar;
|
||||
|
||||
|
||||
-- Procédure de test de la fonction tri
|
||||
-- cf ../../Test_tri pour d'autres algorithmes de tri
|
||||
procedure test_tri is
|
||||
test_tri1 : nbr(1..10) := (5,4,8,3,9,1,6,7,2,0);
|
||||
test_tri2 : nbr(1..10) := (5,4,8,6,9,1,6,7,7,0);
|
||||
begin
|
||||
tri(test_tri2);
|
||||
tri_inverse(test_tri1);
|
||||
|
||||
for i in test_tri1'First..test_tri1'Last loop
|
||||
put(Integer'Image(test_tri1(i))& " ");
|
||||
end loop;
|
||||
Put_Line("");
|
||||
for i in test_tri2'First..test_tri2'Last loop
|
||||
put(Integer'Image(test_tri2(i))& " ");
|
||||
end loop;
|
||||
Put_Line("");
|
||||
end test_tri;
|
||||
|
||||
|
||||
nombre: Integer := 0;
|
||||
begin
|
||||
-- Detection de boucle:
|
||||
data_dect(WST) := 1; --le premier rang écrit par défaut est le 1
|
||||
data_dect(FND) := 0; --aucune boucle n'est trouvé au début
|
||||
|
||||
--Put_Line("Test du programme :");
|
||||
--test_tri;
|
||||
|
||||
|
||||
--
|
||||
Put("Algorithme de Kaprekar. Saisir un nombre : ");
|
||||
Ada.Integer_Text_IO.Get(nombre);
|
||||
|
||||
kaprekar(nombre);
|
||||
|
||||
Put_Line("ALGORITHME FINI");
|
||||
|
||||
|
||||
-- Exceptions
|
||||
exception
|
||||
when Constraint_Error => Put_Line("Nombre donné non valide.");
|
||||
when Storage_Error => Put_Line("DATA_BASE_TOO_SHORT, data_dect(WST):"&Integer'Image(data_dect(WST)));
|
||||
when others => Put_line("Nombre non valide ou trop grand !");
|
||||
end Main;
|
二進制
semestre3/Test_Tri/test_tri
可執行檔
二進制
semestre3/Test_Tri/test_tri
可執行檔
未顯示二進位檔案。
288
semestre3/Test_Tri/test_tri.adb
一般檔案
288
semestre3/Test_Tri/test_tri.adb
一般檔案
|
@ -0,0 +1,288 @@
|
|||
with ada.Text_IO, Ada.Integer_Text_IO;
|
||||
with Ada.Numerics.Discrete_Random;
|
||||
with Ada.Command_Line;
|
||||
|
||||
use ada.Text_IO;
|
||||
use Ada.Command_Line;
|
||||
|
||||
-- Lib C pour intefacer avec le system
|
||||
with Interfaces.C; use Interfaces.C;
|
||||
|
||||
procedure Test_Tri is
|
||||
|
||||
-- Variables globales
|
||||
TMP : constant Duration := 0.05;
|
||||
INTE : Integer := 0;
|
||||
|
||||
-- Type tableau
|
||||
type nbr is array (Integer range <>) of Integer;
|
||||
type Grille is array (Integer range <>, Integer range <>) of character;
|
||||
subtype Double is Integer range 0..65535;
|
||||
|
||||
-- Pointeurs
|
||||
type P_procedure is access procedure (Tab, Aff : in out Nbr);
|
||||
|
||||
-- Package pour l'aléatoire
|
||||
package Aleatoire is new Ada.Numerics.Discrete_Random(Double);
|
||||
use Aleatoire;
|
||||
Hasard : Generator;
|
||||
|
||||
-- Commandes systeme via C
|
||||
function System (Cmd : Interfaces.C.Char_Array) return Interfaces.C.int;
|
||||
pragma Import (C, System, "system");
|
||||
|
||||
|
||||
-- Procédure d'affichage d'un tableau de manière graphique
|
||||
procedure Aff (Tab : in Nbr) is
|
||||
Hauteur : constant Integer := 40;
|
||||
Value : Integer := 0;
|
||||
G : Grille(Tab'First..Hauteur, Tab'range) := (others => (others => ' '));
|
||||
Max : Integer := 0;
|
||||
Err : Interfaces.C.int;
|
||||
begin
|
||||
Err := System("clear");
|
||||
-- Recherche du max
|
||||
for K in Tab'Range loop
|
||||
if Value < Tab(K) then
|
||||
Max := K;
|
||||
Value := Tab(K);
|
||||
end if;
|
||||
end loop;
|
||||
Value := 0;
|
||||
-- Préparation affichage
|
||||
for I in Tab'Range loop
|
||||
Value := ((Tab(I)*Hauteur)/(Tab(Max)+1));
|
||||
for J in G'First(2)..Value loop
|
||||
G(J,I) := '|';
|
||||
end loop;
|
||||
end loop;
|
||||
--Affichage
|
||||
for H in G'Range(1) loop
|
||||
for V in G'Range(2) loop
|
||||
Put(G(G'Last-H+1,V) & "");
|
||||
end loop;
|
||||
New_Line;
|
||||
end loop;
|
||||
--delay 0.05;
|
||||
end Aff;
|
||||
|
||||
|
||||
-- Procédure de tri d'un tableau (Tri bulle)
|
||||
procedure Tri_Bulle (Tab, Affi : in out Nbr) is
|
||||
K : Integer := 0; -- buffer
|
||||
begin
|
||||
for J in Tab'Range loop
|
||||
for I in Tab'First..(Tab'Last - 1) loop
|
||||
if Tab(I + 1) < Tab(I) then
|
||||
K := Tab(I + 1);
|
||||
Tab(I + 1) := Tab(I);
|
||||
Tab(I) := K;
|
||||
end if;
|
||||
end loop;
|
||||
Aff(Tab);
|
||||
delay TMP;
|
||||
end loop;
|
||||
end Tri_Bulle;
|
||||
|
||||
|
||||
-- Tri selection
|
||||
procedure Tri_Selection (Tab, Affi : in out Nbr) is
|
||||
VMin : Integer := Integer'last;
|
||||
Min : Integer := 0;
|
||||
Buffer : Integer;
|
||||
begin
|
||||
for J in Tab'Range loop
|
||||
Vmin := Integer'Last;
|
||||
for I in ((Tab'First+J-1))..Tab'last loop
|
||||
if VMin > Tab(I) then
|
||||
VMin := Tab(I);
|
||||
Min := I;
|
||||
end if;
|
||||
end loop;
|
||||
Buffer := Tab(Tab'First+J-1);
|
||||
Tab(Tab'First+J-1) := Tab(Min);
|
||||
Tab(Min) := Buffer;
|
||||
Aff(Tab);
|
||||
delay TMP;
|
||||
end loop;
|
||||
end Tri_Selection;
|
||||
|
||||
|
||||
-- Tri selection - Version inversée
|
||||
procedure Tri_Selection_Inv (Tab, Affi : in out Nbr) is
|
||||
VMax : Integer := 0;
|
||||
Max : Integer := 0;
|
||||
Buffer : Integer;
|
||||
begin
|
||||
for J in Tab'Range loop
|
||||
Vmax := 0;
|
||||
for I in ((Tab'First+J-1))..Tab'last loop
|
||||
if VMax < Tab(I) then
|
||||
VMax := Tab(I);
|
||||
Max := I;
|
||||
end if;
|
||||
end loop;
|
||||
Buffer := Tab(Tab'First+J-1);
|
||||
Tab(Tab'First+J-1) := Tab(Max);
|
||||
Tab(Max) := Buffer;
|
||||
Aff(Tab);
|
||||
delay TMP;
|
||||
end loop;
|
||||
end Tri_Selection_Inv;
|
||||
|
||||
-- Quicksort
|
||||
procedure Quicksort (A, affi : in out Nbr) is
|
||||
procedure Swap(Left, Right : Natural) is
|
||||
Temp : Integer := A (Left);
|
||||
begin
|
||||
A (Left) := A (Right);
|
||||
A (Right) := Temp;
|
||||
end Swap;
|
||||
|
||||
begin
|
||||
if A'Length > 1 then
|
||||
declare
|
||||
Pivot_Value : Integer := A (A'First);
|
||||
Right : Natural := A'Last;
|
||||
Left : Natural := A'First;
|
||||
begin
|
||||
loop
|
||||
while Left < Right and not (Pivot_Value < A (Left)) loop
|
||||
Left := Natural'Succ (Left);
|
||||
end loop;
|
||||
while Pivot_Value < A (Right) loop
|
||||
Right := Natural'Pred (Right);
|
||||
end loop;
|
||||
exit when Right <= Left;
|
||||
Swap (Left, Right);
|
||||
Left := Natural'Succ (Left);
|
||||
Right := Natural'Pred (Right);
|
||||
end loop;
|
||||
if Right = A'Last then
|
||||
Right := Natural'Pred (Right);
|
||||
Swap (A'First, A'Last);
|
||||
end if;
|
||||
if Left = A'First then
|
||||
Left := Natural'Succ (Left);
|
||||
end if;
|
||||
Affi(A'First..A'Last) := A;
|
||||
Aff(Affi);
|
||||
Quicksort (A (A'First .. Right), Affi);
|
||||
Quicksort (A (Left .. A'Last), Affi);
|
||||
end;
|
||||
end if;
|
||||
end Quicksort;
|
||||
|
||||
-- Tri stupide
|
||||
procedure Tri_Stupide(T, Affi : in out Nbr) is
|
||||
function Ordonne(T : in Nbr) return Boolean is
|
||||
Ord : Boolean := True;
|
||||
I : Integer := T'First;
|
||||
begin
|
||||
-- Ordonné ?
|
||||
while Ord and I < T'last loop
|
||||
if T(I) > T(I+1) then
|
||||
Ord := False;
|
||||
end if;
|
||||
I := I + 1;
|
||||
end loop;
|
||||
return Ord;
|
||||
end Ordonne;
|
||||
-- Mélange
|
||||
procedure Melange(T : in out Nbr) is
|
||||
J, Aux : Integer;
|
||||
begin
|
||||
INTE := INTE + 1;
|
||||
for I in T'Range loop
|
||||
J := (Random(Hasard) mod I) + 1;
|
||||
if J < I then
|
||||
Aux := T(I);
|
||||
T(I) := T(J);
|
||||
T(J) := Aux;
|
||||
end if;
|
||||
end loop;
|
||||
end Melange;
|
||||
begin
|
||||
while not Ordonne(T) loop
|
||||
Melange(T);
|
||||
Aff(T);
|
||||
delay TMP;
|
||||
end loop;
|
||||
Aff(T);
|
||||
end Tri_Stupide;
|
||||
|
||||
|
||||
-- Test de la procédure tri
|
||||
procedure Test_Tri (F : P_Procedure) is
|
||||
test_tri1 : nbr(1..80);
|
||||
begin
|
||||
Put_Line("------------------");
|
||||
for J in Test_Tri1'Range loop
|
||||
Test_Tri1(J) := Random(Hasard);
|
||||
end loop;
|
||||
|
||||
F(Test_Tri1, Test_tri1);
|
||||
end Test_tri;
|
||||
|
||||
F : P_Procedure;
|
||||
F1 : P_Procedure;
|
||||
F2, F3 : P_Procedure;
|
||||
Iteration : Integer := 1;
|
||||
Go : Boolean := False;
|
||||
Err : Interfaces.C.int;
|
||||
begin
|
||||
--Renitialisation du générateur
|
||||
Reset(Hasard);
|
||||
if Argument_Count = 1 then
|
||||
if Argument(1) = "--help" then
|
||||
Put_Line("Algorithme d'affichage d'algorithme de tri");
|
||||
Put_Line("Compatible avec les sytemes UNIX uniquement");
|
||||
New_Line;
|
||||
Put_Line("Le nombre d'itération peut être donné en argument");
|
||||
Put_Line("Argument -r pour un tri inverse");
|
||||
elsif Argument(1) = "-r" then
|
||||
F1 := Tri_Selection_Inv'Access;
|
||||
Test_Tri(F1);
|
||||
else
|
||||
Iteration := Integer'Value(Argument(1));
|
||||
Go := True;
|
||||
end if;
|
||||
else
|
||||
New_Line;
|
||||
--Put("Nbr de boucles : ");
|
||||
--Ada.Integer_Text_IO.Get(Iteration);
|
||||
Go := True;
|
||||
end if;
|
||||
|
||||
if Go then
|
||||
for I in 1..Iteration loop
|
||||
--Test des fonctions
|
||||
F := Tri_Stupide'Access;
|
||||
F1 := Tri_Bulle'Access;
|
||||
F2 := Tri_Selection'Access;
|
||||
F3 := Quicksort'Access;
|
||||
|
||||
Err := System("clear");
|
||||
Put_Line("TRI SELECTION :");
|
||||
delay 2.0;
|
||||
Test_Tri(F2);
|
||||
|
||||
Err := System("clear");
|
||||
Put_Line("TRI BULLE :");
|
||||
delay 2.0;
|
||||
Test_Tri(F1);
|
||||
|
||||
Err := System("clear");
|
||||
Put_Line("TRI RAPIDE :");
|
||||
delay 2.0;
|
||||
Test_Tri(F3);
|
||||
|
||||
Err := System("clear");
|
||||
Put_Line("TRI STUPIDE :");
|
||||
delay 2.0;
|
||||
Test_Tri(F);
|
||||
end loop;
|
||||
end if;
|
||||
|
||||
Put_Line(Integer'Image(INTE));
|
||||
end Test_Tri;
|
二進制
semestre3/chaine_caracteres/chaine
可執行檔
二進制
semestre3/chaine_caracteres/chaine
可執行檔
未顯示二進位檔案。
|
@ -0,0 +1,100 @@
|
|||
with ada.Text_IO, Ada.Integer_Text_IO;
|
||||
with ada.Calendar;
|
||||
|
||||
use ada.Text_IO;
|
||||
|
||||
procedure Chaine is
|
||||
-- Sous-types & variables globales
|
||||
LMT : constant Integer := 100; -- Taille maximun du traitement
|
||||
Type Buffer is array (1..LMT) of Character;
|
||||
type Position is record
|
||||
Debut : Integer;
|
||||
Fin : Integer;
|
||||
end record;
|
||||
|
||||
|
||||
-- Lecture d'entrée console
|
||||
function Lire_Entree return String is
|
||||
Saisie : String (1..LMT);
|
||||
Last : Natural;
|
||||
begin
|
||||
Get_Line(Saisie, Last);
|
||||
declare
|
||||
Phrase : String(Saisie'First..(Last+2));
|
||||
begin
|
||||
Phrase(Phrase'First) := ' ';
|
||||
Phrase(Phrase'Last) := ' ';
|
||||
Phrase((Phrase'First+1)..(Phrase'Last-1)) := Saisie((Saisie'First)..Last);
|
||||
return Phrase;
|
||||
end;
|
||||
end Lire_Entree;
|
||||
|
||||
|
||||
-- Extrait le premier mot d'un string
|
||||
function Extraire_Mot(Text : in out String; Trouve : out Boolean) return Position is
|
||||
I : Integer := 1;
|
||||
Pos : Position;
|
||||
Fin : Boolean := False;
|
||||
begin
|
||||
Trouve := True;
|
||||
|
||||
while Text(I) = ' ' and not Fin loop
|
||||
I := I + 1;
|
||||
if I >= Text'Last then
|
||||
Trouve := False;
|
||||
Fin := True;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
Pos.Debut := I;
|
||||
|
||||
while not Fin loop
|
||||
if Text(I) = ' ' then
|
||||
Fin := True;
|
||||
else
|
||||
I := I + 1;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
Pos.Fin := I;
|
||||
|
||||
for J in Text'First..I loop
|
||||
Text(J) := ' ';
|
||||
end loop;
|
||||
|
||||
return Pos;
|
||||
End Extraire_Mot;
|
||||
|
||||
|
||||
-- Procedure de recherche de mot
|
||||
procedure Fnd_Mot (Txt : String) is
|
||||
Fini : Boolean := False;
|
||||
Compteur : Integer := 0;
|
||||
Pos : Position;
|
||||
Trouve : Boolean;
|
||||
Text : String(Txt'Range) := Txt; -- question de compatibilité
|
||||
|
||||
begin
|
||||
while not Fini loop
|
||||
Pos := Extraire_Mot(Text, Trouve);
|
||||
|
||||
if not Trouve then
|
||||
Fini := True;
|
||||
Put_Line("Extraction terminée");
|
||||
else
|
||||
Compteur := Compteur + 1;
|
||||
Put("Mot n°" & Integer'Image(Compteur) & " trouvé : ");
|
||||
for I in Pos.Debut..Pos.Fin loop
|
||||
Put(Txt(I));
|
||||
Text(I) := ' ';
|
||||
end loop;
|
||||
New_Line;
|
||||
end if;
|
||||
end loop;
|
||||
end Fnd_Mot;
|
||||
|
||||
|
||||
begin
|
||||
Put_Line("Saisir une phrase : ");
|
||||
Fnd_Mot(Lire_Entree);
|
||||
end Chaine;
|
|
@ -0,0 +1,11 @@
|
|||
with Ada.Text_Io;
|
||||
|
||||
procedure Afficher_Test(Objet_du_Test, Attendu, Obtenu : in String) is
|
||||
begin
|
||||
Ada.Text_Io.New_Line;
|
||||
Ada.Text_Io.Put_Line("-----------------------------------------------------------");
|
||||
Ada.Text_Io.Put_Line(Objet_du_Test);
|
||||
Ada.Text_Io.Put_Line("Resultat attendu : " & Attendu);
|
||||
Ada.Text_Io.Put_Line("Resultat obtenu : " & Obtenu);
|
||||
Ada.Text_Io.New_Line;
|
||||
end Afficher_Test;
|
|
@ -0,0 +1 @@
|
|||
procedure Afficher_Test(Objet_du_Test, Attendu, Obtenu : in String);
|
104
semestre3/piles/piles_entiers.adb
一般檔案
104
semestre3/piles/piles_entiers.adb
一般檔案
|
@ -0,0 +1,104 @@
|
|||
-- Auteurs : P. Esquirol
|
||||
-- Version du 30/01/2019
|
||||
|
||||
-- Sous-programmes à compléter
|
||||
-- Init_Pile
|
||||
-- Est_Vide
|
||||
-- Sommet
|
||||
-- Empiler
|
||||
-- Depiler
|
||||
-- Hauteur
|
||||
-- Liste_To_String
|
||||
-- To_String
|
||||
|
||||
with Unchecked_Deallocation;
|
||||
|
||||
package body Piles_Entiers is
|
||||
|
||||
procedure Free is new Unchecked_Deallocation(Cellule, Liste);
|
||||
-- Desallocation d'une Cellule pointee par un pointeur de type Liste
|
||||
-- Procedure utilisee lors des operations Depiler(P) et Vider(P)
|
||||
|
||||
procedure Init(P : in out Pile) is
|
||||
-- Ne fait rien si P est deja vide a l'appel
|
||||
-- Sinon efface tous les elements de P (en
|
||||
-- recuperant la memoire allouee)
|
||||
-- et retourne la pile vide
|
||||
begin
|
||||
null; -- A COMPLETER;
|
||||
end Init;
|
||||
|
||||
function Est_Vide(P : in Pile) return Boolean is
|
||||
-- Retourne vrai si la pile est vide, faux sinon
|
||||
begin
|
||||
return true; -- A COMPLETER
|
||||
end Est_Vide;
|
||||
|
||||
function Sommet(P : in Pile) return Integer is
|
||||
-- Retourne le premier element de P (situe au sommet)
|
||||
begin
|
||||
return 666; -- A COMPLETER
|
||||
end Sommet;
|
||||
|
||||
procedure Empiler(E : in Integer; P : in out Pile) is
|
||||
-- Empile E au dessus de P ; E devient le nouveau sommet
|
||||
begin
|
||||
null; -- A COMPLETER
|
||||
end Empiler;
|
||||
|
||||
procedure Depiler(P: in out Pile) is
|
||||
-- Efface le sommet de P ; attention, penser a recuperer
|
||||
-- la memoire associee a la cellule a effacer
|
||||
begin
|
||||
null; -- A COMPLETER
|
||||
end Depiler;
|
||||
|
||||
function Hauteur(P : in Pile) return Natural is
|
||||
-- Calculer la hauteur en comptant le nombre d'elements depilables
|
||||
-- n'est pas efficace. Cette fonction retourne directement le champ
|
||||
-- hauteur du record associe a une pile
|
||||
begin
|
||||
return 0; -- A COMPLETER
|
||||
end Hauteur;
|
||||
|
||||
function Liste_To_String(L : Liste) return String is
|
||||
-- Convertit une liste d'entiers en une chaine de caracteres
|
||||
begin
|
||||
return ""; -- A COMPLETER
|
||||
end Liste_To_String;
|
||||
|
||||
function To_String(P : in Pile) return String is
|
||||
-- Convertit une pile d'entiers en une chaine de caracteres
|
||||
begin
|
||||
return ""; -- A COMPLETER
|
||||
end To_String;
|
||||
|
||||
function "="(P1,P2 : in Pile) return Boolean is
|
||||
-- Verifie que les piles sont identiques (memes elements et meme ordre)
|
||||
begin
|
||||
return FALSE; -- A COMPLETER
|
||||
end "=";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- procedure Free_Liste(L : in out Liste) is
|
||||
-- -- Desallocation de toutes les Cellules d'une Liste
|
||||
-- begin
|
||||
-- if L /= null then
|
||||
-- Free_Liste(L.All.Suiv); -- desallocation de la liste suivante PUIS
|
||||
-- Free(L); -- desallocation de le premiere cellule
|
||||
-- end if;
|
||||
-- L := null; -- en principe c'est le cas apres Free(L)
|
||||
-- end Free_Liste;
|
||||
|
||||
-- procedure Vider(P : in out Pile) is -- pas indispensable pour le paquetage
|
||||
-- begin
|
||||
-- --A COMPLETER EVENTUELLEMENT (reutiliser Free_Liste)
|
||||
-- end Vider;
|
||||
|
||||
end Piles_Entiers;
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
-- Auteurs : P. Esquirol
|
||||
-- Version du 30/01/2019
|
||||
|
||||
package Piles_Entiers is
|
||||
|
||||
type Pile is limited private;
|
||||
|
||||
Pile_Vide : exception;
|
||||
-- exception levee si on tente d'acceder au sommet d'une pile vide
|
||||
-- ou si on tente de depiler une pile vide.
|
||||
|
||||
-- ****************************************
|
||||
-- OPERATIONS INDISPENSABLES DU T.A.D. PILE
|
||||
-- ****************************************
|
||||
|
||||
procedure Init(P : in out Pile);
|
||||
-- Ne fait rien si P est deja vide a l'appel
|
||||
-- Sinon efface tous les elements de P (en
|
||||
-- recuperant la memoire allouee)
|
||||
-- et retourne la pile vide
|
||||
|
||||
function Est_Vide(P : in Pile) return Boolean;
|
||||
-- Retourne vrai si la pile est vide, faux sinon
|
||||
|
||||
function Sommet(P : in Pile) return Integer;
|
||||
-- Retourne le premier element de P (situe au sommet)
|
||||
|
||||
procedure Empiler(E : in Integer; P : in out Pile);
|
||||
-- Empile E au dessus de P ; E devient le nouveau sommet
|
||||
|
||||
procedure Depiler(P: in out Pile);
|
||||
-- Efface le sommet de P ; attention, penser a recuperer
|
||||
-- la memoire associee a la cellule a effacer
|
||||
|
||||
-- **************************************
|
||||
-- OPERATIONS FACULTATIVES DU T.A.D. PILE
|
||||
-- **************************************
|
||||
|
||||
function Hauteur(P : in Pile) return Natural;
|
||||
-- Calculer la hauteur en comptant le nombre d'elements depilables
|
||||
-- n'est pas efficace. Cette fonction accede directement au champ
|
||||
-- hauteur du record associe a une pile
|
||||
|
||||
function To_String(P : in Pile) return String;
|
||||
-- Convertit une pile d'entiers en une chaine de caracteres
|
||||
|
||||
function "="(P1,P2 : in Pile) return boolean;
|
||||
-- Verifie que les piles sont identiques (memes elements et meme ordre)
|
||||
|
||||
private
|
||||
type Cellule;
|
||||
type Liste is access Cellule;
|
||||
type Cellule is record
|
||||
Info : Integer;
|
||||
Suiv : Liste;
|
||||
end record;
|
||||
|
||||
type Pile is record
|
||||
Debut : Liste := null;
|
||||
Hauteur: Natural := 0;
|
||||
end record;
|
||||
|
||||
end Piles_Entiers;
|
|
@ -0,0 +1,98 @@
|
|||
-- Auteurs : P. Esquirol
|
||||
-- Version du 30/01/2019
|
||||
|
||||
with Ada.Text_Io, Piles_Entiers, Afficher_Test;
|
||||
use Ada.Text_Io, Piles_Entiers;
|
||||
|
||||
procedure Tests_Piles_Entiers is
|
||||
begin
|
||||
---------------------------------------------------------
|
||||
-- 1. Tests apres la declaration et acces a une pile vide
|
||||
---------------------------------------------------------
|
||||
Put_Line("Test 1 : apres Declaration d'une pile P");
|
||||
declare
|
||||
P : Pile;
|
||||
begin
|
||||
Afficher_Test("Est_Vide(P) ?", "TRUE", Boolean'Image(Est_Vide(P)));
|
||||
Afficher_Test("Hauteur(P) ?", "0 ", Integer'Image(Hauteur(P)));
|
||||
Afficher_Test("To_String(P) ?", " ", To_String(P));
|
||||
end;
|
||||
New_Line;
|
||||
Put_Line("Test 2: Tentative d'acces au sommet d'une pile vide");
|
||||
declare
|
||||
P : Pile;
|
||||
Nb : Integer;
|
||||
begin
|
||||
Nb := Sommet(P);
|
||||
Afficher_Test("Sommet(P) ?", "levee exception", Integer'Image(Nb));
|
||||
Put_Line("bizarre ... l'exception n'a pas ete levee ... ");
|
||||
exception
|
||||
when Pile_Vide =>
|
||||
Put_Line("ok, l'exception Pile_Vide a ete levee !!");
|
||||
end;
|
||||
|
||||
---------------------
|
||||
-- 2. Tests d'empiler
|
||||
---------------------
|
||||
declare
|
||||
P : Pile;
|
||||
begin
|
||||
New_Line;
|
||||
Put_Line("Test 3 : Empiler 10 entiers ");
|
||||
--
|
||||
-- ... <<< A COMPLETER
|
||||
--
|
||||
end;
|
||||
|
||||
--------------------------------
|
||||
-- 3. Tests de Depiler et Sommet
|
||||
--------------------------------
|
||||
declare
|
||||
P : Pile;
|
||||
Nb : Integer;
|
||||
begin
|
||||
-- Empiler 10 elements
|
||||
--
|
||||
-- ... <<< A COMPLETER
|
||||
--
|
||||
New_Line;
|
||||
Put_Line("Test 4: Affichage du sommet et depilement pendant 10 fois ...");
|
||||
|
||||
-- Verifier que la pile est bien vide apres 10 appels a Depiler
|
||||
--
|
||||
-- ... <<< A COMPLETER
|
||||
--
|
||||
New_Line;
|
||||
Put_Line("Test 5: Tentative de depilement d'une pile vide ...");
|
||||
--
|
||||
-- ... <<< A COMPLETER
|
||||
--
|
||||
end;
|
||||
|
||||
-----------------------------------
|
||||
-- 4. Test sur l'egalite de 2 piles
|
||||
-----------------------------------
|
||||
Put_Line("Test 6 : Initialisation de 2 piles P1 et P2, et comparaison, ajout de 10 elements et comparaison");
|
||||
declare
|
||||
P1, P2 : Pile;
|
||||
begin
|
||||
null;
|
||||
-- P1 et P2 viennent d'etre declarees, elles sont donc vides
|
||||
-- Verifier qu'elles sont identiques (P1=P2)
|
||||
New_Line;
|
||||
Put_Line("Test 6 : Deux piles vides sont-elles identiques ?");
|
||||
--
|
||||
-- ... <<< A COMPLETER
|
||||
--
|
||||
New_Line;
|
||||
Put_line("On empile desormais 10 entiers 1..10 sur les 2 piles");
|
||||
--
|
||||
-- ... <<< A COMPLETER
|
||||
--
|
||||
New_Line;
|
||||
Put_Line("Test 7 : Deux piles contenant 1..10 sont-elles identiques ?");
|
||||
--
|
||||
-- ... <<< A COMPLETER
|
||||
--
|
||||
end;
|
||||
end Tests_Piles_Entiers;
|
未顯示二進位檔案。
|
@ -0,0 +1,298 @@
|
|||
with Ada.Text_IO;
|
||||
with Ada.Integer_text_IO;
|
||||
use Ada.Text_IO;
|
||||
|
||||
procedure Pointeurs is
|
||||
|
||||
package Int renames Ada.Integer_Text_Io;
|
||||
|
||||
--types
|
||||
type Cellule;
|
||||
type Liste is access Cellule;
|
||||
type Cellule is record
|
||||
Info : Integer;
|
||||
Suiv : Liste;
|
||||
end record;
|
||||
|
||||
Ajout_Imp : exception;
|
||||
|
||||
-----------------------------
|
||||
-- TD4 : pointeurs 1 --
|
||||
-----------------------------
|
||||
|
||||
-- Procédure d'affichage d'une liste
|
||||
procedure Afficher (Lst2 : in Liste) is
|
||||
Aff : Boolean := True;
|
||||
Lst : Liste := Lst2;
|
||||
begin
|
||||
Put("[ ");
|
||||
|
||||
if Lst = null then Aff := False; end if;
|
||||
|
||||
while aff loop
|
||||
if Lst.all.Suiv = null then
|
||||
Aff := False;
|
||||
end if;
|
||||
Put(Integer'Image(Lst.all.Info) & " ;");
|
||||
Lst := Lst.all.Suiv;
|
||||
end loop;
|
||||
Put_Line("]");
|
||||
end Afficher;
|
||||
|
||||
|
||||
-- Procédure d'affichage en sens inverse d'une liste
|
||||
procedure Afficher_Inverse(Lst : in Liste) is
|
||||
begin
|
||||
if Lst.all.Suiv /= null then
|
||||
Afficher_Inverse(Lst.all.suiv);
|
||||
end if;
|
||||
Put(Integer'Image(Lst.all.Info) & " ;");
|
||||
end Afficher_Inverse;
|
||||
|
||||
|
||||
-- Procédure qui compte le nb d'éléments d'une liste
|
||||
function Compte (Lst2 : in Liste) return Integer is
|
||||
Lst : Liste := Lst2;
|
||||
Compteur : Integer := 0;
|
||||
begin
|
||||
if Lst /= null then
|
||||
Compteur := 1;
|
||||
while Lst.all.Suiv /= null loop
|
||||
Compteur := Compteur +1;
|
||||
Lst := Lst.all.Suiv;
|
||||
end loop;
|
||||
end if;
|
||||
--Put_Line("Cette liste possède " & Integer'Image(Compteur) & " cellules");
|
||||
return Compteur;
|
||||
end Compte;
|
||||
|
||||
|
||||
--Procédure d'ajout d'élément en fin de liste de valeur V
|
||||
procedure Ajout_Cellule (Lst2 : in out Liste; V : integer) is
|
||||
Lst : Liste := Lst2;
|
||||
begin
|
||||
if Lst = null then
|
||||
Lst2 := new Cellule'(V, null);
|
||||
else
|
||||
while Lst.all.Suiv /= null loop
|
||||
Lst := Lst.all.Suiv;
|
||||
end loop;
|
||||
Lst.all.Suiv := new Cellule'(V, null);
|
||||
end if;
|
||||
--Put_Line("Cellule ajoutée en fin de liste. Valeur : " & Integer'Image(V));
|
||||
end Ajout_Cellule;
|
||||
|
||||
procedure AJ_Rec (Lst2 : in out Liste; V : Integer) is
|
||||
begin
|
||||
if Lst2 = null then
|
||||
Lst2 := new Cellule'(V, null);
|
||||
else
|
||||
AJ_Rec(Lst2.all.Suiv, V);
|
||||
end if;
|
||||
end AJ_Rec;
|
||||
|
||||
|
||||
-- Fonction de suppression d'un element n
|
||||
function Del_Elem (Lst : Liste; N : Integer) return Liste is
|
||||
Lst2 : Liste := Lst;
|
||||
begin
|
||||
if N <= 0 or N > Compte(Lst) then
|
||||
raise Ajout_Imp;
|
||||
elsif N = 1 then
|
||||
Lst2 := Lst.all.Suiv;
|
||||
else
|
||||
for I in 2..N-1 loop
|
||||
Lst2 := Lst2.all.Suiv;
|
||||
end loop;
|
||||
Lst2.all.suiv := Lst2.all.Suiv.all.Suiv;
|
||||
Lst2 := Lst;
|
||||
end if;
|
||||
|
||||
return Lst2;
|
||||
end Del_Elem;
|
||||
|
||||
|
||||
|
||||
-- Procédure qui éclate la liste en une liste de nb pairs et une autre impaires
|
||||
function Trier_Liste(Lst : in out Liste) return Liste is
|
||||
Lst_Impaire : Liste := null;
|
||||
Lst_Buffer : Liste := Lst;
|
||||
I : Integer := 1;
|
||||
Nb_Enl : Integer := 0;
|
||||
begin
|
||||
while Lst_Buffer /= null loop
|
||||
if (Float((Lst_Buffer.all.Info / 2)) = Float(Lst_buffer.all.Info)/2.0) then -- si info pair
|
||||
null;
|
||||
else
|
||||
AJ_Rec(Lst_Impaire, Lst_Buffer.all.Info);
|
||||
--Ajout_Cellule(Lst_Impaire, Lst_buffer.all.Info);
|
||||
|
||||
Lst := Del_Elem(Lst, I - Nb_enl);
|
||||
Nb_Enl := Nb_Enl + 1;
|
||||
end if;
|
||||
Lst_Buffer := Lst_Buffer.all.Suiv;
|
||||
I := I + 1;
|
||||
end loop;
|
||||
return Lst_impaire;
|
||||
end Trier_Liste;
|
||||
|
||||
|
||||
|
||||
-----------------------------
|
||||
-- TD5 : pointeurs 2 --
|
||||
-----------------------------
|
||||
|
||||
-- Fonction copie - Version récursive
|
||||
function Copie(Lst : in Liste) return Liste is
|
||||
begin
|
||||
if Lst = null then
|
||||
return null;
|
||||
else
|
||||
return new Cellule'(Lst.all.Info, Copie(Lst.all.suiv));
|
||||
end if;
|
||||
end Copie;
|
||||
|
||||
|
||||
-- Procédure de concaténation avec destruction
|
||||
procedure Concatenation(L1, L2 : in out Liste) is
|
||||
L1buf : Liste := L1;
|
||||
begin
|
||||
while L1buf.all.suiv /= null loop
|
||||
L1buf := L1buf.all.Suiv;
|
||||
end loop;
|
||||
L1buf.all.Suiv := L2;
|
||||
L2 := null;
|
||||
end Concatenation;
|
||||
|
||||
|
||||
-- Fonction de concaténation sans destruction
|
||||
function Concatenation_safe(L1, L2 : in Liste) return Liste is
|
||||
L1buf : Liste := null;
|
||||
L1bufaux : Liste := null;
|
||||
begin
|
||||
L1buf := Copie(L1);
|
||||
L1bufaux := L1buf;
|
||||
while L1bufaux.all.suiv /= null loop
|
||||
L1bufaux := L1bufaux.all.Suiv;
|
||||
end loop;
|
||||
L1bufaux.all.Suiv := L2;
|
||||
return L1buf;
|
||||
end Concatenation_safe;
|
||||
|
||||
|
||||
-- Fonction de fusion
|
||||
function Fusion(L1, L2 : in Liste) return Liste is
|
||||
M1 : Liste := L1;
|
||||
M2 : Liste := L2;
|
||||
Fusion : Liste := null;
|
||||
begin
|
||||
while ((M1 /= null) and (M2 /= null)) loop
|
||||
if (M1.all.Info <= M2.all.Info) then
|
||||
Ajout_Cellule(Fusion, M1.all.Info);
|
||||
M1 := M1.all.Suiv;
|
||||
else
|
||||
Ajout_Cellule(Fusion, M2.all.Info);
|
||||
M2 := M2.all.Suiv;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
if M1 = null then
|
||||
Concatenation(Fusion, M2);
|
||||
elsif M2 = null then
|
||||
Concatenation(Fusion, M1);
|
||||
end if;
|
||||
|
||||
return Fusion;
|
||||
end Fusion;
|
||||
|
||||
|
||||
-- Fonction interactive de saisie de liste
|
||||
function Saisir_Liste return Liste is
|
||||
N : Integer := 0;
|
||||
Lst : Liste := null;
|
||||
begin
|
||||
Put_Line("Saisir une liste de nombre : ");
|
||||
while not End_Of_Line loop
|
||||
Int.Get(N);
|
||||
Ajout_Cellule(Lst, N);
|
||||
end loop;
|
||||
Put_Line("Liste créée : ");
|
||||
Afficher(Lst);
|
||||
return Lst;
|
||||
end Saisir_Liste;
|
||||
|
||||
|
||||
-- Fonction interactive de saisie de liste - version 2 : on utilise pas Ajout_cellule()
|
||||
function Saisir_Liste_2 return Liste is
|
||||
N : Integer := 0;
|
||||
Lst : Liste := null;
|
||||
P_Fin : Liste := null;
|
||||
begin
|
||||
Put_Line("Saisir une liste de nombre : ");
|
||||
while not End_Of_Line loop
|
||||
Int.Get(N);
|
||||
if Lst = null then
|
||||
Lst := new Cellule'(N, null);
|
||||
P_Fin := Lst;
|
||||
else
|
||||
P_Fin.all.Suiv := new Cellule'(N, null);
|
||||
P_Fin := P_Fin.all.Suiv;
|
||||
end if;
|
||||
end loop;
|
||||
Put_Line("Liste créée : ");
|
||||
Afficher(Lst);
|
||||
return Lst;
|
||||
end Saisir_Liste_2;
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------------------
|
||||
-----------------------------
|
||||
|
||||
|
||||
|
||||
L : Liste := null;
|
||||
L2 : Liste := null;
|
||||
L3 : Liste := null;
|
||||
L4 : Liste := null;
|
||||
begin
|
||||
-----------------------------
|
||||
-- TD4 : pointeurs 1 --
|
||||
-----------------------------
|
||||
for I in 1..10 loop
|
||||
Ajout_Cellule(L,I);
|
||||
end loop;
|
||||
--Ajout_Cellule(L,22);
|
||||
--Ajout_Cellule(L,41);
|
||||
--
|
||||
--Afficher(L);
|
||||
--New_Line;
|
||||
--Put_Line("Tri des nb pairs et impairs");
|
||||
--Afficher(Trier_Liste(L));
|
||||
--Afficher(L);
|
||||
|
||||
-----------------------------
|
||||
-- TD5 : pointeurs 2 --
|
||||
-----------------------------
|
||||
-- Création des listes
|
||||
L2 := Copie(L);
|
||||
Ajout_Cellule(L, 22);
|
||||
Ajout_Cellule(L3, 3);
|
||||
Ajout_Cellule(L3, 5);
|
||||
Ajout_Cellule(L3, 7);
|
||||
Ajout_Cellule(L3, 9);
|
||||
|
||||
--Afficher_Inverse(L);
|
||||
--Afficher(L);
|
||||
--Afficher(L2);
|
||||
--Afficher(L3);
|
||||
--Afficher(Concatenation_safe(L, L2));
|
||||
--Afficher(L);
|
||||
--Afficher(L2);
|
||||
--Afficher(Fusion(L3,L));
|
||||
|
||||
L4 := Saisir_Liste_2;
|
||||
exception
|
||||
when Ajout_Imp => Put_Line("Tentative d'accès à une cellule inexistante");
|
||||
end Pointeurs;
|
未顯示二進位檔案。
|
@ -0,0 +1,115 @@
|
|||
with Ada.Text_IO;
|
||||
with Ada.Integer_text_IO;
|
||||
use Ada.Text_IO;
|
||||
|
||||
procedure Processeur is
|
||||
|
||||
package Int renames Ada.Integer_Text_Io;
|
||||
|
||||
--types
|
||||
type process is record
|
||||
Num : Integer; --PID
|
||||
Dur : Integer; --Quantum
|
||||
end record;
|
||||
|
||||
type Tache;
|
||||
type Liste is access Tache;
|
||||
type Tache is record
|
||||
Info : Process;
|
||||
Suiv : Liste;
|
||||
end record;
|
||||
|
||||
Q : constant Natural := 1;
|
||||
|
||||
--------------------------
|
||||
-- TP4 : Séance 2 --
|
||||
--------------------------
|
||||
|
||||
-- Procédure d'affichage d'une liste
|
||||
procedure Afficher (Lst2 : in Liste) is
|
||||
Aff : Boolean := True;
|
||||
Lst : Liste := Lst2;
|
||||
Debut : Integer := 0;
|
||||
begin
|
||||
Put(" [ ");
|
||||
|
||||
if Lst = null then Aff := False; end if;
|
||||
|
||||
Debut := Lst.all.Info.Num;
|
||||
while aff loop
|
||||
if Lst.all.Suiv.all.Info.Num = debut then
|
||||
Aff := False;
|
||||
end if;
|
||||
Put("PID:" & Integer'Image(Lst.all.Info.Num) & ",Q=" & Integer'Image(Lst.all.Info.Dur) & "; ");
|
||||
Lst := Lst.all.Suiv;
|
||||
end loop;
|
||||
Put_Line("]");
|
||||
New_Line;
|
||||
end Afficher;
|
||||
|
||||
-- Fonction de suppression d'élément
|
||||
function Del_Tache (N : Integer; Lst2 : in Liste) return Liste is
|
||||
Lst : Liste := Lst2;
|
||||
Prec : Liste := Lst2;
|
||||
begin
|
||||
while Lst.all.Info.Num /= N loop
|
||||
Lst := Lst.all.Suiv;
|
||||
end loop;
|
||||
while Prec.all.Suiv /= Lst loop
|
||||
Prec := Prec.all.Suiv;
|
||||
end loop;
|
||||
if Prec.all.Suiv = Lst.all.Suiv then
|
||||
Lst := null;
|
||||
Put_Line("Tache n°" & Integer'Image(N) & " supprimée.");
|
||||
else
|
||||
Prec.all.Suiv := Lst.all.Suiv;
|
||||
Lst := Lst.all.Suiv;
|
||||
Put_Line("Tache n°" & Integer'Image(N) & " supprimée.");
|
||||
end if;
|
||||
return Lst;
|
||||
end Del_Tache;
|
||||
|
||||
|
||||
|
||||
-- fonction d'initialisation de la machine (création des taches)
|
||||
function Init return Liste is
|
||||
Lst : Liste := null;
|
||||
P_Lst : Liste := null;
|
||||
begin
|
||||
Lst := new Tache'((1,3), new Tache'((2,5), new Tache'((3,2), new Tache'((4,3), null))));
|
||||
P_Lst := Lst;
|
||||
while P_Lst.all.suiv /= null loop
|
||||
P_Lst := P_Lst.all.Suiv;
|
||||
end loop;
|
||||
P_Lst.all.Suiv := Lst;
|
||||
Afficher(Lst);
|
||||
return Lst;
|
||||
end Init;
|
||||
|
||||
-- procedure de gestion des taches
|
||||
procedure Processeur(Lst : in out Liste) is
|
||||
begin
|
||||
while Lst /= null loop
|
||||
Lst.all.Info.Dur := Lst.all.Info.Dur - Q;
|
||||
Put_Line("La tâche n°" & Integer'Image(Lst.all.Info.Num) & " est passée dans le processeur pendant un quantum.");
|
||||
|
||||
if Lst.all.Info.Dur <= 0 then
|
||||
Put("Une tâche est terminée. ");
|
||||
Lst := Del_Tache(Lst.all.Info.Num, Lst);
|
||||
if Lst /= null then
|
||||
Lst := Lst.all.Suiv;
|
||||
--Afficher(Lst);
|
||||
end if;
|
||||
else
|
||||
Lst := Lst.all.Suiv;
|
||||
--Afficher(Lst);
|
||||
end if;
|
||||
end loop;
|
||||
Put_Line("La liste des tâches est vide. Fin d'éxécution.");
|
||||
end Processeur;
|
||||
|
||||
Lst : Liste := null;
|
||||
begin
|
||||
Lst := Init;
|
||||
Processeur(Lst);
|
||||
end Processeur;
|
二進制
semestre3/recursivite/binome/binome
可執行檔
二進制
semestre3/recursivite/binome/binome
可執行檔
未顯示二進位檔案。
|
@ -0,0 +1,34 @@
|
|||
with Ada.Text_Io;
|
||||
with Ada.Command_Line;
|
||||
|
||||
use Ada.Command_Line;
|
||||
use Ada.Text_Io;
|
||||
|
||||
procedure Binome is
|
||||
|
||||
-- Fonction de calcul de coef. binomiaux
|
||||
function C(P : Integer; N : Integer) return Integer is
|
||||
Coef : Integer := 1;
|
||||
begin
|
||||
if P = 0 or N = P then
|
||||
Coef := 1;
|
||||
else
|
||||
Coef := C(P-1, N-1) + C(P, N-1);
|
||||
end if;
|
||||
return Coef;
|
||||
end C;
|
||||
|
||||
-- Procédure de test de C
|
||||
procedure Test_C(N : Integer) is
|
||||
begin
|
||||
for P in 0..N loop
|
||||
Put(Integer'Image(C(P,N)) & " ");
|
||||
end loop;
|
||||
end Test_C;
|
||||
|
||||
|
||||
begin
|
||||
Test_C(Integer'Value((Argument(1))));
|
||||
exception
|
||||
when CONSTRAINT_ERROR => Put_Line("1 argument attendu : valeur de N. Exemple : ./binome 7.");
|
||||
end Binome;
|
二進制
semestre3/recursivite/koch/koch
可執行檔
二進制
semestre3/recursivite/koch/koch
可執行檔
未顯示二進位檔案。
|
@ -0,0 +1,57 @@
|
|||
-- Compilation possible uniquement à l'INSA
|
||||
with Tortue;
|
||||
with Ada.Text_Io;
|
||||
use Tortue;
|
||||
use Ada.Text_Io;
|
||||
|
||||
procedure Koch is
|
||||
|
||||
-- Procedure récursive pour tracer des courbes
|
||||
procedure Courbe (Finesse: Integer; Longueur : Integer) is
|
||||
begin
|
||||
if Finesse = 1 then
|
||||
Avancer(Float(Longueur));
|
||||
else
|
||||
Courbe(Finesse - 1, Longueur / 4);
|
||||
Tourner_Gauche (60.0);
|
||||
Courbe(Finesse - 1, Longueur / 4);
|
||||
Tourner_Droite(120.0);
|
||||
Courbe(Finesse - 1, Longueur / 4);
|
||||
Tourner_Gauche(60.0);
|
||||
Courbe(Finesse - 1, Longueur / 4);
|
||||
end if;
|
||||
end Courbe;
|
||||
|
||||
|
||||
-- Procédure pour tracer un flocon
|
||||
procedure Flocon(Finesse: Integer; Longueur : Integer) is
|
||||
begin
|
||||
for I in 1..3 loop
|
||||
Courbe(Finesse, Longueur);
|
||||
Tourner_Droite(120.0);
|
||||
end loop;
|
||||
end Flocon;
|
||||
|
||||
|
||||
-- Initialisation de tortue
|
||||
procedure Init is
|
||||
begin
|
||||
Ouvrir_Fenetre;
|
||||
Lever_Crayon;
|
||||
Aller_A(300,400);
|
||||
Tourner_Droite(90.0);
|
||||
Baisser_Crayon;
|
||||
end Init;
|
||||
|
||||
-- Procédure de test
|
||||
procedure Test_Koch is
|
||||
Pixel : Integer := 1000;
|
||||
begin
|
||||
Init;
|
||||
Flocon(4, pixel);
|
||||
end Test_Koch;
|
||||
|
||||
|
||||
begin
|
||||
Test_Koch;
|
||||
end Koch;
|
未顯示二進位檔案。
|
@ -0,0 +1,65 @@
|
|||
with Ada.Text_Io;
|
||||
with Ada.Integer_Text_IO;
|
||||
|
||||
use Ada.Integer_Text_IO;
|
||||
use Ada.Text_IO;
|
||||
|
||||
procedure Labyrinthe is
|
||||
|
||||
type Lab is array (Integer range <>, Integer range <>) of Character;
|
||||
|
||||
procedure Aff(L : Lab) is
|
||||
begin
|
||||
for I in L'Range(1) loop
|
||||
for J in L'Range(2) loop
|
||||
Put(L(I,J));
|
||||
end loop;
|
||||
New_Line;
|
||||
end loop;
|
||||
New_Line(2);
|
||||
end Aff;
|
||||
|
||||
procedure Trouver_Sortie(L : in out Lab; X : Integer; Y : Integer) is
|
||||
begin
|
||||
if L(X,Y) = 'H' then
|
||||
raise STORAGE_ERROR;
|
||||
end if;
|
||||
|
||||
if X = L'First or Y = L'First or X = L'Last or Y = L'Last then
|
||||
null;
|
||||
else
|
||||
if L(X+1,Y) = '.' then
|
||||
Trouver_Sortie(L, X+1, Y);
|
||||
elsif L(X,Y+1) = '.' then
|
||||
Trouver_Sortie(L, X, Y+1);
|
||||
elsif L(X-1,Y) = '.' then
|
||||
Trouver_Sortie(L, X-1, Y);
|
||||
elsif L(X,Y-1) = '.' then
|
||||
Trouver_Sortie(L, X, Y-1);
|
||||
end if;
|
||||
end if;
|
||||
L(X,Y) := '@';
|
||||
Put_Line("(" & Integer'Image(X) & "; " & Integer'Image(Y) & ")");
|
||||
Aff(L);
|
||||
end Trouver_Sortie;
|
||||
|
||||
subtype Dim is Integer range 1..7;
|
||||
Mon_Lab : Lab (Dim, Dim):= (('H','H','H','H','H','H','H'),
|
||||
('H','.','.','.','.','.','H'),
|
||||
('H','H','H','H','.','H','H'),
|
||||
('H','.','.','.','.','H','H'),
|
||||
('H','.','.','H','.','H','H'),
|
||||
('H','.','.','.','.','.','H'),
|
||||
('H','H','H','H','H','.','H'));
|
||||
Numero_Ligne_Depart, Numero_Colonne_Depart : Dim;
|
||||
Sortie_Trouvee : boolean := False;
|
||||
begin
|
||||
Aff(Mon_Lab);
|
||||
put("Position initiale : ");
|
||||
get(Numero_Ligne_Depart);
|
||||
get(Numero_Colonne_Depart);
|
||||
Trouver_Sortie(Mon_Lab, Numero_Ligne_Depart, Numero_Colonne_Depart);
|
||||
|
||||
exception
|
||||
when STORAGE_ERROR => Put_Line("Le Labyrinthe n'a pas de sortie !");
|
||||
end Labyrinthe;
|
未顯示二進位檔案。
|
@ -0,0 +1,51 @@
|
|||
with Ada.Text_Io;
|
||||
with Ada.Command_Line;
|
||||
|
||||
use Ada.Command_Line;
|
||||
use Ada.Text_IO;
|
||||
|
||||
procedure Palin is
|
||||
|
||||
function Is_Palin(W : String) return Boolean is
|
||||
begin
|
||||
if W'Length <= 1 then
|
||||
return True;
|
||||
else
|
||||
if Character(W(W'First)) = Character(W(W'Last)) then
|
||||
return Is_Palin(W(W'First + 1..W'Last - 1));
|
||||
else
|
||||
return False;
|
||||
end if;
|
||||
end if;
|
||||
end Is_Palin;
|
||||
|
||||
function Is_Palin_Ite(W : String) return Boolean is
|
||||
P : Boolean := True;
|
||||
begin
|
||||
for I in W'First..(W'Length / 2) loop
|
||||
if (W(I..I)) /= (W(W'Last - I + 1..W'Last - I + 1
|
||||
)) then
|
||||
P := False;
|
||||
end if;
|
||||
end loop;
|
||||
return P;
|
||||
end Is_Palin_Ite;
|
||||
|
||||
|
||||
begin
|
||||
for I in 1..Argument_Count loop
|
||||
New_Line;
|
||||
Put_Line(Argument(I));
|
||||
if Is_Palin(Argument(I)) then
|
||||
Put_Line("PALINDROME");
|
||||
else
|
||||
Put_Line("bin non en fait...");
|
||||
end if;
|
||||
|
||||
if Is_Palin_ite(Argument(I)) then
|
||||
Put_Line("PALINDROME");
|
||||
else
|
||||
Put_Line("bin non en fait...");
|
||||
end if;
|
||||
end loop;
|
||||
end Palin;
|
未顯示二進位檔案。
|
@ -0,0 +1,21 @@
|
|||
with Ada.Text_Io;
|
||||
use Ada.Text_IO;
|
||||
|
||||
procedure Somme is
|
||||
|
||||
-- Type
|
||||
type Tab is array(Integer range <>) of Float;
|
||||
|
||||
function Add(T : Tab) return Float is
|
||||
begin
|
||||
if T'Length <= 1 then
|
||||
return T(T'Last);
|
||||
else
|
||||
return T(T'First) + Add(T(T'First + 1.. T'Last));
|
||||
end if;
|
||||
end Add;
|
||||
|
||||
T : Tab := (1.0, 1.5, 4.3);
|
||||
begin
|
||||
Put_Line(Float'Image(Add(T)));
|
||||
end Somme;
|
未顯示二進位檔案。
|
@ -0,0 +1,77 @@
|
|||
with Ada.Text_Io;
|
||||
with Ada.Integer_Text_IO;
|
||||
use Ada.Text_IO;
|
||||
|
||||
procedure Recursivite is
|
||||
-- Types
|
||||
type Vector is array (Integer range <>) of Integer;
|
||||
|
||||
-- Fonction dichotomique de recherche
|
||||
function Dichoto(V : Vector; Value : integer) return Integer is
|
||||
Middle : Integer := V'First + (((V'Last)-(V'First)) / 2);
|
||||
Find : Boolean := False;
|
||||
begin
|
||||
--Etude des cas
|
||||
if (V'Length = 2 and V(V'First) /= Middle and V(V'Last) /= Middle) or Middle = 0 then
|
||||
Middle := 0;
|
||||
return Middle;
|
||||
end if;
|
||||
|
||||
if Value > V(Middle) then
|
||||
declare
|
||||
V2 : Vector(Middle..V'Last) := V(Middle..V'Last);
|
||||
begin
|
||||
Middle := Dichoto(V2, Value);
|
||||
end;
|
||||
elsif V(Middle) > Value then
|
||||
declare
|
||||
V2 : Vector(V'First..Middle) := V(V'First..Middle);
|
||||
begin
|
||||
Middle := Dichoto(V2, Value);
|
||||
end;
|
||||
else
|
||||
null;
|
||||
end if;
|
||||
return Middle;
|
||||
end Dichoto;
|
||||
|
||||
--Procédure de test de Dichoto
|
||||
procedure Test_Dichoto(V : Vector; Value : Integer) is
|
||||
begin
|
||||
Put_Line(" Tableau saisie : ");
|
||||
for I in V'Range loop
|
||||
Put(Integer'Image(V(I)) & " ");
|
||||
end loop;
|
||||
New_Line;
|
||||
Put_Line("Valeur recherchée : " & Integer'Image(Value));
|
||||
if Dichoto(V, Value) /= 0 then
|
||||
Put_Line("Valeur trouvée : " & Integer'Image(V(Dichoto(V, Value))));
|
||||
else
|
||||
Put_Line("La valeur n'existe pas dans le tableau");
|
||||
end if;
|
||||
end Test_Dichoto;
|
||||
|
||||
-- Fonction factorielle récursive
|
||||
function Factorielle(N : Integer) return Integer is
|
||||
Resultat : Integer;
|
||||
begin
|
||||
if N = 0 then
|
||||
Resultat := 1;
|
||||
else
|
||||
Resultat := N* Factorielle(N-1);
|
||||
end if;
|
||||
return Resultat;
|
||||
end Factorielle;
|
||||
|
||||
V1 : Vector(1..20) := (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
|
||||
V2 : Vector(1..20) := (11,29,30,46,56,64,71,89,98,107,110,123,133,145,150,168,171,189,193,210);
|
||||
N : Integer;
|
||||
begin
|
||||
Test_Dichoto(V1, 16);
|
||||
Test_Dichoto(V2, 56);
|
||||
Test_Dichoto(V2, 31);
|
||||
|
||||
Put("Factorielle de : ");
|
||||
Ada.Integer_Text_IO.Get(N);
|
||||
Put_Line(Integer'Image(Factorielle(N)));
|
||||
end Recursivite;
|
|
@ -0,0 +1,11 @@
|
|||
with Ada.Text_Io;
|
||||
|
||||
procedure Afficher_Test(Objet_du_Test, Attendu, Obtenu : in String) is
|
||||
begin
|
||||
Ada.Text_Io.New_Line;
|
||||
Ada.Text_Io.Put_Line("-----------------------------------------------------------");
|
||||
Ada.Text_Io.Put_Line(Objet_du_Test);
|
||||
Ada.Text_Io.Put_Line("Resultat attendu : " & Attendu);
|
||||
Ada.Text_Io.Put_Line("Resultat obtenu : " & Obtenu);
|
||||
Ada.Text_Io.New_Line;
|
||||
end Afficher_Test;
|
|
@ -0,0 +1 @@
|
|||
procedure Afficher_Test(Objet_du_Test, Attendu, Obtenu : in String);
|
|
@ -0,0 +1,145 @@
|
|||
-- Auteurs : P. E.
|
||||
-- Version du 30/01/2019
|
||||
|
||||
-- Sous-programmes à compléter
|
||||
-- Init_Pile
|
||||
-- Est_Vide
|
||||
-- Sommet
|
||||
-- Empiler
|
||||
-- Depiler
|
||||
-- Hauteur
|
||||
-- Liste_To_String
|
||||
-- To_String
|
||||
|
||||
with Unchecked_Deallocation;
|
||||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
|
||||
package body Piles_Entiers is
|
||||
|
||||
procedure Free is new Unchecked_Deallocation(Cellule, Liste);
|
||||
-- Desallocation d'une Cellule pointee par un pointeur de type Liste
|
||||
-- Procedure utilisee lors des operations Depiler(P) et Vider(P)
|
||||
|
||||
procedure Vide_Liste(L : in out Liste) is
|
||||
begin
|
||||
if L /= null then
|
||||
Vide_Liste(L.all.Suiv);
|
||||
Free(L.all.Suiv);
|
||||
end if;
|
||||
end Vide_Liste;
|
||||
|
||||
procedure Init(P : in out Pile) is
|
||||
-- Ne fait rien si P est deja vide a l'appel
|
||||
-- Sinon efface tous les elements de P (en
|
||||
-- recuperant la memoire allouee)
|
||||
-- et retourne la pile vide
|
||||
begin
|
||||
Vide_Liste(P.Debut);
|
||||
Free(P.Debut);
|
||||
end Init;
|
||||
|
||||
function Est_Vide(P : in Pile) return Boolean is
|
||||
-- Retourne vrai si la pile est vide, faux sinon
|
||||
begin
|
||||
return (P.Debut = null);
|
||||
end Est_Vide;
|
||||
|
||||
function Sommet(P : in Pile) return Integer is
|
||||
-- Retourne le premier element de P (situe au sommet)
|
||||
begin
|
||||
if Est_Vide(P) then
|
||||
raise Pile_Vide;
|
||||
end if;
|
||||
return P.Debut.all.info;
|
||||
end Sommet;
|
||||
|
||||
procedure Empiler(E : in Integer; P : in out Pile) is
|
||||
-- Empile E au dessus de P ; E devient le nouveau sommet
|
||||
begin
|
||||
P.Debut := new Cellule'(E, P.Debut);
|
||||
P.Hauteur := P.Hauteur + 1;
|
||||
end Empiler;
|
||||
|
||||
procedure Depiler(P: in out Pile) is
|
||||
-- Efface le sommet de P ; attention, penser a recuperer
|
||||
-- la memoire associee a la cellule a effacer
|
||||
Buffer : Liste;
|
||||
begin
|
||||
if Est_Vide(P) then
|
||||
raise Pile_Vide;
|
||||
end if;
|
||||
Buffer := P.Debut;
|
||||
P.Debut := P.Debut.all.Suiv;
|
||||
Free(Buffer);
|
||||
P.Hauteur := P.Hauteur - 1;
|
||||
exception
|
||||
when Pile_Vide => Put_Line("Tentative de pull une liste vide !");
|
||||
end Depiler;
|
||||
|
||||
function Hauteur(P : in Pile) return Natural is
|
||||
-- Calculer la hauteur en comptant le nombre d'elements depilables
|
||||
-- n'est pas efficace. Cette fonction retourne directement le champ
|
||||
-- hauteur du record associe a une pile
|
||||
begin
|
||||
return P.Hauteur;
|
||||
end Hauteur;
|
||||
|
||||
function Liste_To_String(L : Liste) return String is
|
||||
-- Convertit une liste d'entiers en une chaine de caracteres
|
||||
begin
|
||||
if L /= null then
|
||||
return Integer'Image(L.all.Info) & " - " & Liste_To_String(L.all.Suiv);
|
||||
else
|
||||
return ";";
|
||||
end if;
|
||||
end Liste_To_String;
|
||||
|
||||
function To_String(P : in Pile) return String is
|
||||
-- Convertit une pile d'entiers en une chaine de caracteres
|
||||
begin
|
||||
return Liste_To_String(P.Debut);
|
||||
end To_String;
|
||||
|
||||
function "="(P1,P2 : in Pile) return Boolean is
|
||||
-- Verifie que les piles sont identiques (memes elements et meme ordre)
|
||||
L, L2 : Liste;
|
||||
Egal : Boolean := true;
|
||||
begin
|
||||
L := P1.Debut;
|
||||
L2 := P2.Debut;
|
||||
while L /= null and L2 /= null and Egal = True loop
|
||||
if L.all.Info /= L2.all.info then
|
||||
Egal := False;
|
||||
end if;
|
||||
L := L.all.Suiv;
|
||||
L2 := L2.all.Suiv;
|
||||
end loop;
|
||||
if L /= null or L2 /= null then
|
||||
Egal := False;
|
||||
end if;
|
||||
return Egal;
|
||||
end "=";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- procedure Free_Liste(L : in out Liste) is
|
||||
-- -- Desallocation de toutes les Cellules d'une Liste
|
||||
-- begin
|
||||
-- if L /= null then
|
||||
-- Free_Liste(L.All.Suiv); -- desallocation de la liste suivante PUIS
|
||||
-- Free(L); -- desallocation de le premiere cellule
|
||||
-- end if;
|
||||
-- L := null; -- en principe c'est le cas apres Free(L)
|
||||
-- end Free_Liste;
|
||||
|
||||
-- procedure Vider(P : in out Pile) is -- pas indispensable pour le paquetage
|
||||
-- begin
|
||||
-- --A COMPLETER EVENTUELLEMENT (reutiliser Free_Liste)
|
||||
-- end Vider;
|
||||
|
||||
end Piles_Entiers;
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
-- Auteurs : P. E.
|
||||
-- Version du 30/01/2019
|
||||
|
||||
package Piles_Entiers is
|
||||
|
||||
type Pile is limited private;
|
||||
|
||||
Pile_Vide : exception;
|
||||
-- exception levee si on tente d'acceder au sommet d'une pile vide
|
||||
-- ou si on tente de depiler une pile vide.
|
||||
|
||||
-- ****************************************
|
||||
-- OPERATIONS INDISPENSABLES DU T.A.D. PILE
|
||||
-- ****************************************
|
||||
|
||||
procedure Init(P : in out Pile);
|
||||
-- Ne fait rien si P est deja vide a l'appel
|
||||
-- Sinon efface tous les elements de P (en
|
||||
-- recuperant la memoire allouee)
|
||||
-- et retourne la pile vide
|
||||
|
||||
function Est_Vide(P : in Pile) return Boolean;
|
||||
-- Retourne vrai si la pile est vide, faux sinon
|
||||
|
||||
function Sommet(P : in Pile) return Integer;
|
||||
-- Retourne le premier element de P (situe au sommet)
|
||||
|
||||
procedure Empiler(E : in Integer; P : in out Pile);
|
||||
-- Empile E au dessus de P ; E devient le nouveau sommet
|
||||
|
||||
procedure Depiler(P: in out Pile);
|
||||
-- Efface le sommet de P ; attention, penser a recuperer
|
||||
-- la memoire associee a la cellule a effacer
|
||||
|
||||
-- **************************************
|
||||
-- OPERATIONS FACULTATIVES DU T.A.D. PILE
|
||||
-- **************************************
|
||||
|
||||
function Hauteur(P : in Pile) return Natural;
|
||||
-- Calculer la hauteur en comptant le nombre d'elements depilables
|
||||
-- n'est pas efficace. Cette fonction accede directement au champ
|
||||
-- hauteur du record associe a une pile
|
||||
|
||||
function To_String(P : in Pile) return String;
|
||||
-- Convertit une pile d'entiers en une chaine de caracteres
|
||||
|
||||
function "="(P1,P2 : in Pile) return boolean;
|
||||
-- Verifie que les piles sont identiques (memes elements et meme ordre)
|
||||
|
||||
private
|
||||
type Cellule;
|
||||
type Liste is access Cellule;
|
||||
type Cellule is record
|
||||
Info : Integer;
|
||||
Suiv : Liste;
|
||||
end record;
|
||||
|
||||
type Pile is record
|
||||
Debut : Liste := null;
|
||||
Hauteur: Natural := 0;
|
||||
end record;
|
||||
|
||||
end Piles_Entiers;
|
二進制
semestre4/TP1_piles/post_fixee
可執行檔
二進制
semestre4/TP1_piles/post_fixee
可執行檔
未顯示二進位檔案。
134
semestre4/TP1_piles/post_fixee.adb
一般檔案
134
semestre4/TP1_piles/post_fixee.adb
一般檔案
|
@ -0,0 +1,134 @@
|
|||
with Ada.Text_Io, Piles_Entiers, Afficher_Test;
|
||||
use Ada.Text_Io, Piles_Entiers;
|
||||
|
||||
procedure Post_Fixee is
|
||||
|
||||
type Tab is array (Character range 'A'..'Z') of Integer;
|
||||
|
||||
Symbole_Inconnu : exception;
|
||||
Manque_Operande : exception;
|
||||
Manque_Operateur : exception;
|
||||
|
||||
procedure Lire_Entree(E : in out String; T : in out Tab) is
|
||||
Len : Integer := 0;
|
||||
begin
|
||||
Get_Line(E, len);
|
||||
for I in Len+1..E'Last loop
|
||||
E(I) := ' ';
|
||||
end loop;
|
||||
|
||||
for J in 1..Len loop
|
||||
case E(J) is
|
||||
when 'A'..'Z' =>
|
||||
Put("Quelle est la valeur de " & Character'Image(E(J)) & " ?");
|
||||
T(E(J)) := Integer'Value(Get_line);
|
||||
when others => null;
|
||||
end case;
|
||||
end loop;
|
||||
|
||||
end Lire_Entree;
|
||||
|
||||
procedure Chk(P : in out Pile) is
|
||||
begin
|
||||
if Hauteur(P) < 2 then
|
||||
raise Manque_Operande;
|
||||
end if;
|
||||
end Chk;
|
||||
|
||||
|
||||
procedure Somme(P : in out Pile) is
|
||||
A,B : Integer;
|
||||
begin
|
||||
Chk(P);
|
||||
A := Sommet(P);
|
||||
Depiler(P);
|
||||
B := Sommet(P);
|
||||
Depiler(P);
|
||||
Empiler(A+B, P);
|
||||
end Somme;
|
||||
|
||||
procedure Souss(P : in out Pile) is
|
||||
A,B : Integer;
|
||||
begin
|
||||
Chk(P);
|
||||
A := Sommet(P);
|
||||
Depiler(P);
|
||||
B := Sommet(P);
|
||||
Depiler(P);
|
||||
Empiler(B-A, P);
|
||||
end Souss;
|
||||
|
||||
procedure Mult(P : in out Pile) is
|
||||
A,B : Integer;
|
||||
begin
|
||||
Chk(P);
|
||||
A := Sommet(P);
|
||||
Depiler(P);
|
||||
B := Sommet(P);
|
||||
Depiler(P);
|
||||
Empiler(A*B, P);
|
||||
end Mult;
|
||||
|
||||
procedure Div(P : in out Pile) is
|
||||
A,B : Integer;
|
||||
begin
|
||||
Chk(P);
|
||||
A := Sommet(P);
|
||||
Depiler(P);
|
||||
B := Sommet(P);
|
||||
Depiler(P);
|
||||
Empiler(B/A, P);
|
||||
end Div;
|
||||
|
||||
function Eval_Exp_PostFixee(E : String; T : Tab) return Integer is
|
||||
P : Pile;
|
||||
begin
|
||||
Init(P);
|
||||
Put_Line(E);
|
||||
for I in E'First..E'Last loop
|
||||
case E(I) is
|
||||
when 'A'..'Z' => Empiler(T(E(I)), P);
|
||||
when '+' => Somme(P);
|
||||
when '-' => Souss(P);
|
||||
when '*' => Mult(P);
|
||||
when '/' => Div(P);
|
||||
when ' ' => null;
|
||||
when others => raise Symbole_Inconnu;
|
||||
end case;
|
||||
end loop;
|
||||
|
||||
if Hauteur(P) /= 1 then
|
||||
raise Manque_Operateur;
|
||||
end if;
|
||||
|
||||
return Sommet(P);
|
||||
end Eval_Exp_PostFixee;
|
||||
|
||||
procedure display is
|
||||
E : String(1..20);
|
||||
Len : Integer := 0;
|
||||
T : Tab;
|
||||
begin
|
||||
for I in T'Range loop
|
||||
T(I) := Len;
|
||||
Len := Len + 1;
|
||||
--Put_Line(I & " : " & Integer'Image(T(I)));
|
||||
end loop;
|
||||
|
||||
Put_Line("Saisir l'expression : ");
|
||||
Lire_Entree(E, T);
|
||||
|
||||
Put_Line(Integer'Image(Eval_Exp_PostFixee(E, T)));
|
||||
|
||||
exception
|
||||
when Symbole_Inconnu => Put_Line("Un des caractères saisis est non valide."); Display;
|
||||
when Manque_Operande => Put_Line("Le nombre d'opérandes n'est pas valide."); Display;
|
||||
when Manque_Operateur => Put_Line("Le nombre d'opérateurs n'est pas valide."); Display;
|
||||
end Display;
|
||||
|
||||
|
||||
begin
|
||||
<<Entry0>>
|
||||
Put_Line("Programme d'interprétation de chaine de calcul postfixee : ");
|
||||
Display;
|
||||
end Post_Fixee;
|
未顯示二進位檔案。
|
@ -0,0 +1,107 @@
|
|||
-- Auteurs : P. E.
|
||||
-- Version du 30/01/2019
|
||||
|
||||
with Ada.Text_Io, Piles_Entiers, Afficher_Test;
|
||||
use Ada.Text_Io, Piles_Entiers;
|
||||
|
||||
procedure Tests_Piles_Entiers is
|
||||
begin
|
||||
---------------------------------------------------------
|
||||
-- 1. Tests apres la declaration et acces a une pile vide
|
||||
---------------------------------------------------------
|
||||
Put_Line("Test 1 : apres Declaration d'une pile P");
|
||||
declare
|
||||
P : Pile;
|
||||
begin
|
||||
Afficher_Test("Est_Vide(P) ?", "TRUE", Boolean'Image(Est_Vide(P)));
|
||||
Afficher_Test("Hauteur(P) ?", "0 ", Integer'Image(Hauteur(P)));
|
||||
Afficher_Test("To_String(P) ?", " ", To_String(P));
|
||||
end;
|
||||
New_Line;
|
||||
Put_Line("Test 2: Tentative d'acces au sommet d'une pile vide");
|
||||
declare
|
||||
P : Pile;
|
||||
Nb : Integer;
|
||||
begin
|
||||
Nb := Sommet(P);
|
||||
Afficher_Test("Sommet(P) ?", "levee exception", Integer'Image(Nb));
|
||||
Put_Line("bizarre ... l'exception n'a pas ete levee ... ");
|
||||
exception
|
||||
when Pile_Vide =>
|
||||
Put_Line("ok, l'exception Pile_Vide a ete levee !!");
|
||||
end;
|
||||
|
||||
---------------------
|
||||
-- 2. Tests d'empiler
|
||||
---------------------
|
||||
declare
|
||||
P : Pile;
|
||||
begin
|
||||
New_Line;
|
||||
Put_Line("Test 3 : Empiler 10 entiers ");
|
||||
for I in 2..12 loop
|
||||
Empiler(I, P);
|
||||
end loop;
|
||||
Put_Line(To_String(P));
|
||||
end;
|
||||
|
||||
--------------------------------
|
||||
-- 3. Tests de Depiler et Sommet
|
||||
--------------------------------
|
||||
declare
|
||||
P : Pile;
|
||||
Nb : Integer;
|
||||
begin
|
||||
-- Empiler 10 elements
|
||||
Init(P);
|
||||
for I in 1..10 loop
|
||||
Empiler(I, P);
|
||||
end loop;
|
||||
New_Line;
|
||||
Put_Line("Test 4: Affichage du sommet et depilement pendant 10 fois ...");
|
||||
|
||||
-- Verifier que la pile est bien vide apres 10 appels a Depiler
|
||||
for J in 1..10 loop
|
||||
Depiler(P);
|
||||
end loop;
|
||||
if Est_Vide(P) then
|
||||
Put_Line("La pile est vide");
|
||||
else
|
||||
Put_Line("TEST 4 FAUTIF");
|
||||
--raise PROGRAM_ERROR;
|
||||
end if;
|
||||
New_Line;
|
||||
Put_Line("Test 5: Tentative de depilement d'une pile vide ...");
|
||||
Init(P);
|
||||
Depiler(P);
|
||||
end;
|
||||
|
||||
-----------------------------------
|
||||
-- 4. Test sur l'egalite de 2 piles
|
||||
-----------------------------------
|
||||
Put_Line("Test 6 : Initialisation de 2 piles P1 et P2, et comparaison, ajout de 10 elements et comparaison");
|
||||
declare
|
||||
P1, P2 : Pile;
|
||||
begin
|
||||
null;
|
||||
-- P1 et P2 viennent d'etre declarees, elles sont donc vides
|
||||
-- Verifier qu'elles sont identiques (P1=P2)
|
||||
New_Line;
|
||||
Put_Line("Test 6 : Deux piles vides sont-elles identiques ?");
|
||||
if P1 = P2 then
|
||||
Put_Line("Elles sont identiques");
|
||||
end if;
|
||||
New_Line;
|
||||
Put_line("On empile desormais 10 entiers 1..10 sur les 2 piles");
|
||||
for I in 2..11 loop
|
||||
Empiler(I, P1);
|
||||
Empiler(I, P2);
|
||||
Put_Line("On empile sur P1 et P2 : " & Integer'Image(I));
|
||||
end loop;
|
||||
New_Line;
|
||||
Put_Line("Test 7 : Deux piles contenant 1..10 sont-elles identiques ?");
|
||||
if P1 = P2 then
|
||||
Put_Line("Identiques");
|
||||
end if;
|
||||
end;
|
||||
end Tests_Piles_Entiers;
|
|
@ -0,0 +1,11 @@
|
|||
with Ada.Text_Io;
|
||||
|
||||
procedure Afficher_Test(Objet_du_Test, Attendu, Obtenu : in String) is
|
||||
begin
|
||||
Ada.Text_Io.New_Line;
|
||||
Ada.Text_Io.Put_Line("-----------------------------------------------------------");
|
||||
Ada.Text_Io.Put_Line(Objet_du_Test);
|
||||
Ada.Text_Io.Put_Line("Resultat attendu : " & Attendu);
|
||||
Ada.Text_Io.Put_Line("Resultat obtenu : " & Obtenu);
|
||||
Ada.Text_Io.New_Line;
|
||||
end Afficher_Test;
|
|
@ -0,0 +1,151 @@
|
|||
with Ada.Unchecked_Deallocation;
|
||||
|
||||
package body Listes_Ordonnees_Entiers is
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
function Est_Vide(L : in Une_Liste_Ordonnee_Entiers) return Boolean is
|
||||
begin
|
||||
return L.Debut = null;
|
||||
end Est_Vide;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
function Cardinal(L : in Une_Liste_Ordonnee_Entiers) return Integer is
|
||||
begin
|
||||
return L.Taille;
|
||||
end Cardinal;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Appartient classique sur une liste simplement chainee (type Lien) ordonnee
|
||||
|
||||
function Appartient_Lien(E : Integer; LL : in Lien) return Boolean is
|
||||
Resultat :boolean;
|
||||
begin
|
||||
if LL = null or else E < LL.all.info then
|
||||
Resultat := False; -- element non trouve
|
||||
elsif LL.all.Info = E then
|
||||
Resultat := True; -- element trouve en 1ere place
|
||||
else
|
||||
Resultat := Appartient_Lien(E, LL.all.Suiv); -- on cherche plus loin
|
||||
end if;
|
||||
return Resultat;
|
||||
end Appartient_Lien;
|
||||
|
||||
-- Appartient sur le type Une_Liste_Ordonnee_Entiers
|
||||
-- On reutilise la fonction classique Appartient_Lien sur L.debut
|
||||
function Appartient(E : in integer; L : in Une_Liste_Ordonnee_Entiers) return Boolean is
|
||||
begin
|
||||
return Appartient_Lien(E, L.Debut);
|
||||
end Appartient;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-- Conversion en chaine de caracteres
|
||||
--
|
||||
-- sur le type Lien
|
||||
|
||||
function Lien_To_String(LL : in Lien) return String is
|
||||
begin
|
||||
if LL = null then return "";
|
||||
else return integer'image(LL.all.info) & Lien_To_String(LL.all.suiv);
|
||||
end if;
|
||||
end Lien_To_String;
|
||||
|
||||
-- sur le type Une_Liste_Ordonnee_Entiers
|
||||
function Liste_To_String(L: in Une_Liste_Ordonnee_Entiers) return String is
|
||||
begin
|
||||
return Integer'Image(L.Taille) & " elements : (" & Lien_To_String(L.Debut) & " )";
|
||||
end Liste_To_String;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-- Insertion ORDONNEE et SANS DOUBLON
|
||||
|
||||
procedure Inserer_Lien(E: in Integer; L: in out Lien) is
|
||||
begin
|
||||
if L = null then
|
||||
L := new Cellule'(E, null);
|
||||
elsif L.Info = E then raise Element_Deja_Present;
|
||||
elsif L.info > E then
|
||||
L := new Cellule'(E, L);
|
||||
else
|
||||
Inserer_Lien(E, L.Suiv);
|
||||
end if;
|
||||
|
||||
-- On desire une version RECURSIVE
|
||||
-- La procedure doit LEVER L'EXCEPTION Element_Deja_Present en
|
||||
-- cas de tentative d'insertion d'un doublon
|
||||
end Inserer_Lien;
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
procedure Inserer(E: in integer; L: in out Une_Liste_Ordonnee_Entiers) is
|
||||
begin
|
||||
Inserer_Lien(E, L.Debut);
|
||||
L.Taille := L.Taille + 1;
|
||||
end Inserer;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
|
||||
-- Instanciation de Ada.Unchecked_Deallocation pour desallouer
|
||||
-- la memoire en cas de suppression des elements d'une liste
|
||||
-------------------------------------------------------------------------
|
||||
procedure Free is new Ada.Unchecked_Deallocation(Cellule, Lien);
|
||||
-------------------------------------------------------------------------
|
||||
procedure Supprimer_Lien(E : in Integer; L: in out Lien) is
|
||||
Recup : Lien;
|
||||
begin
|
||||
if L = null or else E < L.All.Info then
|
||||
raise Element_Non_Present;
|
||||
elsif E = L.All.Info then
|
||||
Recup := L; -- on repere la cellule a recycler
|
||||
L := L.All.Suiv; -- on modifie le debut de la liste
|
||||
Free(Recup); -- on recupere la memoire
|
||||
else
|
||||
Supprimer_Lien(E, L.all.suiv);
|
||||
end if;
|
||||
end Supprimer_Lien;
|
||||
-------------------------------------------------------------------------
|
||||
procedure Supprimer(E: in integer; L: in out Une_Liste_Ordonnee_Entiers) is
|
||||
begin
|
||||
Supprimer_Lien(E, L.debut);
|
||||
L.Taille := L.Taille - 1;
|
||||
end Supprimer;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-- Fonctions facultatives
|
||||
function Egal_Lien(L1, L2 : in Lien) return Boolean is
|
||||
begin
|
||||
if L1 = null and L2 = null then
|
||||
return True;
|
||||
elsif (L1 = null or L2 = null) or (L1.Info /= L2.Info) then
|
||||
return False;
|
||||
elsif L1.Info = L2.Info then
|
||||
return Egal_Lien(L1.all.Suiv, L2.all.Suiv);
|
||||
else
|
||||
return FALSE; -- Ligne de code jamais atteinte, mais supprime des messages d'erreurs à la compilation.
|
||||
end if;
|
||||
end Egal_Lien;
|
||||
|
||||
function "="(L1, L2 : in Une_Liste_Ordonnee_Entiers) return Boolean is
|
||||
begin
|
||||
return Egal_Lien(L1.Debut, L2.Debut);
|
||||
end "=";
|
||||
|
||||
function Copie_Lien(L1: in Lien) return Lien is
|
||||
begin
|
||||
if L1 = null then return null;
|
||||
else return new Cellule'(L1.all.Info, Copie_Lien(L1.all.Suiv));
|
||||
end if;
|
||||
end Copie_Lien;
|
||||
|
||||
procedure Copie(L1 : in Une_Liste_Ordonnee_Entiers; L2 : out Une_Liste_Ordonnee_Entiers) is
|
||||
begin
|
||||
L2.Debut := Copie_lien(L1.Debut);
|
||||
L2.Taille := L1.Taille;
|
||||
end Copie;
|
||||
|
||||
end Listes_Ordonnees_Entiers;
|
|
@ -0,0 +1,41 @@
|
|||
package Listes_Ordonnees_Entiers is
|
||||
|
||||
type Une_Liste_Ordonnee_Entiers is limited private;
|
||||
|
||||
Element_Non_Present, Element_Deja_Present : exception;
|
||||
|
||||
function Est_Vide(L : in Une_Liste_Ordonnee_Entiers) return Boolean;
|
||||
|
||||
function Cardinal(L : in Une_Liste_Ordonnee_Entiers) return Integer;
|
||||
|
||||
function Appartient(E : in integer; L : in Une_Liste_Ordonnee_Entiers) return Boolean;
|
||||
|
||||
procedure Inserer(E: in integer; L: in out Une_Liste_Ordonnee_Entiers);
|
||||
|
||||
procedure Supprimer(E: in integer; L: in out Une_Liste_Ordonnee_Entiers);
|
||||
|
||||
function Liste_To_String(L: in Une_Liste_Ordonnee_Entiers) return String;
|
||||
|
||||
--ajouts de ss-programmes d'egalite et de copie
|
||||
function "="(L1, L2 : in Une_Liste_Ordonnee_Entiers) return Boolean;
|
||||
|
||||
procedure Copie(L1 : in Une_Liste_Ordonnee_Entiers; L2 : out Une_Liste_Ordonnee_Entiers);
|
||||
|
||||
|
||||
private
|
||||
-- types classiques permettant de realiser des listes simplement chainees
|
||||
type Cellule;
|
||||
type Lien is access Cellule;
|
||||
type Cellule is record
|
||||
Info : integer;
|
||||
Suiv : Lien;
|
||||
end record;
|
||||
|
||||
-- type liste ameliore : record contenant la liste et sa taille
|
||||
-- (evite de parcourir la liste pour calculer la taille)
|
||||
|
||||
type Une_Liste_Ordonnee_Entiers is record
|
||||
Debut : Lien := null;
|
||||
Taille : Natural := 0;
|
||||
end record;
|
||||
end Listes_Ordonnees_Entiers;
|
未顯示二進位檔案。
|
@ -0,0 +1,39 @@
|
|||
with Listes_Ordonnees_Entiers; use Listes_Ordonnees_Entiers;
|
||||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
with Afficher_Test;
|
||||
|
||||
procedure Mon_Application is
|
||||
L1, L2 : Une_Liste_Ordonnee_Entiers;
|
||||
begin
|
||||
Put_Line("-----------------------------------------------------------");
|
||||
Put_Line("Etape 1 : Insertion d'elements dans L1");
|
||||
Inserer(3, L1);
|
||||
Inserer(5, L1);
|
||||
Inserer(4, L1);
|
||||
Inserer(2, L1);
|
||||
Put_Line("Contenu de L1 : " & Liste_To_String(L1));
|
||||
|
||||
Put_Line("-----------------------------------------------------------");
|
||||
Put_Line("Etape 2 - Affectation de L1 a L2");
|
||||
|
||||
Copie(L1, L2);
|
||||
Put_Line("Contenu de L2 : " & Liste_To_String(L2));
|
||||
|
||||
Put_Line("-----------------------------------------------------------");
|
||||
Put_Line("Etape 3 - Ajout de 1 a L1 et de 1 a L2");
|
||||
Inserer(1, L1);
|
||||
Inserer(1, L2);
|
||||
Put_Line("Contenu de L1 : " & Liste_To_String(L1));
|
||||
Put_Line("Contenu de L2 : " & Liste_To_String(L2));
|
||||
|
||||
-- Les deux listes sont-elle egales ?
|
||||
Afficher_Test("L1 = L2 ?", "TRUE", Boolean'Image(L1=L2));
|
||||
|
||||
Put_Line("-----------------------------------------------------------");
|
||||
Put_Line("Etape 4 - Ajouts de 2 elements 0 et 6 a L1");
|
||||
Inserer(0, L1);
|
||||
Inserer(6, L1);
|
||||
Put_Line("Contenu de L1 : " & Liste_To_String(L1));
|
||||
Put_Line("Contenu de L2 : " & Liste_To_String(L2));
|
||||
|
||||
end Mon_Application;
|
未顯示二進位檔案。
|
@ -0,0 +1,110 @@
|
|||
with Ada.Text_Io, listes_ordonnees_entiers, Afficher_Test;
|
||||
use Ada.Text_Io, listes_ordonnees_entiers;
|
||||
|
||||
procedure Test_Listes_Ordonnees_Entiers is
|
||||
begin
|
||||
-----------------------------------------------------------
|
||||
-- Test de création
|
||||
-----------------------------------------------------------
|
||||
Put_Line("Test après création");
|
||||
declare
|
||||
L : Une_Liste_Ordonnee_Entiers;
|
||||
begin
|
||||
Afficher_Test("Est_Vide() ?", "TRUE", Boolean'Image(Est_Vide(L)));
|
||||
Afficher_Test("Cardinal() ?", "0", Integer'Image(Cardinal(L)));
|
||||
|
||||
Put_Line("Test d'affichage: ");
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test d'ajout d'éléments
|
||||
-----------------------------------------------------------
|
||||
Put_Line("Test après ajout d'éléments");
|
||||
declare
|
||||
L : Une_Liste_Ordonnee_Entiers;
|
||||
begin
|
||||
Put_Line("Liste créée, on ajout des éléments");
|
||||
Inserer(1,L);
|
||||
Inserer(-1,L);
|
||||
Inserer(3,L);
|
||||
Inserer(45,L);
|
||||
Inserer(2,L);
|
||||
Inserer(9,L);
|
||||
Put_Line("6 éléments ajoutés : [1, -1, 3, 45, 2, 9].");
|
||||
|
||||
Put_Line("Test d'affichage: ");
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
|
||||
Afficher_Test("Est_Vide() ?", "FALSE", Boolean'Image(Est_Vide(L)));
|
||||
Afficher_Test("Cardinal() ?", "6", Integer'Image(Cardinal(L)));
|
||||
Afficher_Test("Appartient(2) ?", "TRUE", Boolean'Image(Appartient(2,L)));
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test de manipulation
|
||||
-----------------------------------------------------------
|
||||
Put_Line("Test de manipulation");
|
||||
declare
|
||||
L : Une_Liste_Ordonnee_Entiers;
|
||||
begin
|
||||
Inserer(1,L); Inserer(-1,L);Inserer(3,L);Inserer(45,L);Inserer(2,L);Inserer(9,L);
|
||||
Put_Line("Liste créée, 6 éléments ajoutés : [1, -1, 3, 45, 2, 9].");
|
||||
Put_Line("Liste: ");
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
Put_Line("On supprime 2:"); Supprimer(2,L);
|
||||
Afficher_Test("Cardinal() ?", "5", Integer'Image(Cardinal(L)));
|
||||
Afficher_Test("Appartient(2) ?", "FALSE", Boolean'Image(Appartient(2,L)));
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test d'exceptions
|
||||
-----------------------------------------------------------
|
||||
declare
|
||||
L : Une_Liste_Ordonnee_Entiers;
|
||||
begin
|
||||
Inserer(1,L); Inserer(-1,L);Inserer(3,L);
|
||||
Put_Line("On supprime un élément inexistant : ");
|
||||
Supprimer(28, L);
|
||||
exception
|
||||
when Element_Non_Present => Put_Line("L'exception Element_Non_Present est correctement levée !");
|
||||
end;
|
||||
declare
|
||||
L : Une_Liste_Ordonnee_Entiers;
|
||||
begin
|
||||
Inserer(1,L); Inserer(-1,L);Inserer(3,L);
|
||||
Put_Line("On ajoute un élément déjà présent : ");
|
||||
Inserer(1, L);
|
||||
exception
|
||||
when Element_Deja_Present => Put_Line("L'exception Element_Deja_Present est correctement levée !");
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test des fonctions auxiliaires
|
||||
-----------------------------------------------------------
|
||||
declare
|
||||
L, L2 : Une_Liste_Ordonnee_Entiers;
|
||||
begin
|
||||
Put_Line("On créé une liste L: ");
|
||||
Inserer(1,L); Inserer(-1,L);Inserer(3,L);
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
Put_Line("On en créé une copie L2: ");
|
||||
Copie(L, L2);
|
||||
Put_Line(Liste_To_String(L2)); New_Line;
|
||||
|
||||
Put_Line("On vérifie qu'elles sont égales:");
|
||||
Afficher_Test("=(L,L2) ?", "TRUE", Boolean'Image(L=L2));
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
New_Line;
|
||||
Put_Line("Fin des tests.");
|
||||
end Test_Listes_Ordonnees_Entiers;
|
|
@ -0,0 +1,10 @@
|
|||
Charles Chang Beziers ORL 0703888032
|
||||
Martha Bibbs Beauvais Psychiatre 0616751216
|
||||
Jerry Joosten Albi Pharmacien 0724258260
|
||||
Elijah Taylor Caen Orthodontiste 0770222606
|
||||
Gary Maupin Bayonne Rhumatologue 0705071875
|
||||
William Snider Tours Radiologue 0621112196
|
||||
Josefa Eckel Villeurbanne Kinesitherapeute 0784142335
|
||||
John Brunton Lorient Oncologue 0617519421
|
||||
Ronald Crank Montreuil Dentiste 0668920050
|
||||
Joanne Ramos Sevran Veterinaire 0657148529
|
|
@ -0,0 +1,100 @@
|
|||
Christina Salvietti Dunkerque Stomatologue 0614557340
|
||||
Thomas Dalton Orleans Rhumatologue 0717045284
|
||||
Michael Hemp Pantin Psychiatre 0789751830
|
||||
Christopher Chalmers Suresnes Veterinaire 0765856048
|
||||
Kathrine Hall Tours Radiologue 0723029341
|
||||
Robin Cook Angers Dermatologue 0771690567
|
||||
Alexander Seaberry Versailles Veterinaire 0688468848
|
||||
Lydia Gunter Montrouge Radiologue 0791786318
|
||||
Ronald Berry Pantin Urologue 0766359222
|
||||
Ralph Getz Perpignan Pediatre 0736397458
|
||||
Sarah Venhorst Arles Cardiologue 0718276125
|
||||
Dorothy Schrenk Dijon Psychiatre 0730529239
|
||||
Valerie Hill Courbevoie Gynecologue 0740938552
|
||||
Bethany Hemmingsen Belfort Pharmacien 0661965668
|
||||
Alex Sircy Carcassonne Dentiste 0767042063
|
||||
Dawn Orduna Limoges Pharmacien 0729276847
|
||||
John Roberts Valence Ophtalmologie 0606017296
|
||||
Kirk Mentzer Beziers Stomatologue 0754938171
|
||||
Rod Brandes Beauvais Ophtalmologie 0677493599
|
||||
Ann Collins Drancy Rhumatologue 0728051106
|
||||
Lyle Lynch Bordeaux Pneumologue 0611081673
|
||||
Daniel Gaytan Nimes Dentiste 0734320107
|
||||
Maria Clayton Cayenne Stomatologue 0707951067
|
||||
Michelle Szaflarski Bourges Rhumatologue 0671359079
|
||||
Connie Myles Rouen Psychiatre 0670774856
|
||||
Michelle Koller Angers Orthodontiste 0789861804
|
||||
Burton Gould Meaux Kinesitherapeute 0759713789
|
||||
William Downs Metz Urologue 0624420780
|
||||
Warren Thacker Cannes Pharmacien 0787114057
|
||||
Gabrielle Atwood Vincennes Kinesitherapeute 0717448326
|
||||
Nancy Schlemmer Cergy Stomatologue 0680012397
|
||||
Joshua Sheahan Belfort ORL 0751676741
|
||||
Janet Matusz Limoges Infirmier 0679596606
|
||||
June Phillips Frejus Cardiologue 0794575429
|
||||
Bonnie Henry Bourges Pharmacien 0733255479
|
||||
Brad Tinajero Niort ORL 0787004064
|
||||
Diane Brody Paris Stomatologue 0619689557
|
||||
Andrew Brizuela Perpignan Veterinaire 0725147359
|
||||
Tiffany Johnson Montpellier Cardiologue 0662233729
|
||||
Jean Ball Beauvais Psychologue 0619930405
|
||||
Edwin Womack Pessac Cardiologue 0610446516
|
||||
Walter Lee Mulhouse Urologue 0736737546
|
||||
Lionel Garrison Sarcelles Urologue 0626162381
|
||||
Ted Ross Limoges Dermatologue 0736812823
|
||||
Joseph Burgos Merignac Dermatologue 0686454461
|
||||
Helen Rudd Suresnes Rhumatologue 0720159880
|
||||
John Edwards Colombes Stomatologue 0786816630
|
||||
Patricia Mckenzie Bayonne Radiologue 0799285175
|
||||
Barry Washington Carcassonne Gynecologue 0629044930
|
||||
Brent Rumph Dunkerque Kinesitherapeute 0601686369
|
||||
Howard Hopper Calais Gynecologue 0736698485
|
||||
Willie Morber Pessac Pharmacien 0684229819
|
||||
Debra Ferro Argenteuil Dermatologue 0715229166
|
||||
Jewell Browne Clamart Infirmier 0613448062
|
||||
Marjorie Phillips Beziers Dentiste 0626771559
|
||||
Bobbie Dickson Roubaix Veterinaire 0752944999
|
||||
Dorothy Taylor Drancy Pneumologue 0727657312
|
||||
Shelley Toure Albi Ophtalmologie 0728248225
|
||||
Jacqueline Lowe Lorient Psychologue 0766130683
|
||||
Thelma Joyce Sartrouville Psychologue 0782053265
|
||||
Taneka Bonnell Nancy Gynecologue 0708715730
|
||||
Johnny Verduzco Martigues Dermatologue 0640313570
|
||||
Lydia Stahnke Perpignan Gynecologue 0654914801
|
||||
Noel Seng Colmar Pharmacien 0640985650
|
||||
Patricia Mancia Nantes Pharmacien 0661452251
|
||||
Andrew Edison Cannes Infirmier 0682646757
|
||||
George Chan Clichy Pediatre 0704365146
|
||||
Laura Krajewski Tours Pneumologue 0728727260
|
||||
Matthew Ringwood Cergy Oncologue 0769681461
|
||||
Kenneth Cox Sevran Pneumologue 0651190403
|
||||
Odell Anderson Dijon Dentiste 0644008941
|
||||
Cynthia Stelling Antony Pneumologue 0709334530
|
||||
Fred Collins Lyon Psychiatre 0768046535
|
||||
Robert Rose Paris Dermatologue 0696752326
|
||||
Ronald Carpenter Tourcoing ORL 0798115523
|
||||
Carolyn Jordan Montrouge Ophtalmologie 0670251464
|
||||
Scott Harris Montpellier Orthodontiste 0671519724
|
||||
John Turner Brest Urologue 0666825542
|
||||
Arturo Strobel Lorient Veterinaire 0718350189
|
||||
Mary Byrd Calais ORL 0770391790
|
||||
Maria Castillo Villejuif Psychiatre 0640320392
|
||||
Helen Smith Venissieux Cardiologue 0710300526
|
||||
Elizabeth Runyon Lyon Cardiologue 0754831274
|
||||
Irma Lebeau Chambery Veterinaire 0622965436
|
||||
Raul Petrick Orleans Gynecologue 0782714832
|
||||
Genevieve White Sartrouville Kinesitherapeute 0701551618
|
||||
Charlotte Allred Lyon Psychologue 0779128443
|
||||
Ashley Golish Clichy Dermatologue 0733829538
|
||||
Christopher Marshall Perpignan Pneumologue 0608430736
|
||||
Patricia Martinez Creteil Urologue 0708675019
|
||||
Shawn Depue Quimper Urologue 0771007917
|
||||
James Whitaker Antibes Rhumatologue 0708105493
|
||||
Venus Heath Merignac Ophtalmologie 0764982294
|
||||
Henry Taylor Quimper Pediatre 0627414030
|
||||
Gerald Ward Antony Infirmier 0760432900
|
||||
Pearlie Wallace Lorient Oncologue 0678446542
|
||||
Darrell Dingman Aubervilliers Pneumologue 0742554197
|
||||
John Wingard Vincennes Rhumatologue 0610835804
|
||||
Regina Mitchell Cergy Kinesitherapeute 0799055623
|
||||
Amanda Johnson Paris Pharmacien 0783971691
|
檔案差異因為檔案過大而被隱藏
載入差異
|
@ -0,0 +1,11 @@
|
|||
with Ada.Text_Io;
|
||||
|
||||
procedure Afficher_Test(Objet_du_Test, Attendu, Obtenu : in String) is
|
||||
begin
|
||||
Ada.Text_Io.New_Line;
|
||||
Ada.Text_Io.Put_Line("-----------------------------------------------------------");
|
||||
Ada.Text_Io.Put_Line(Objet_du_Test);
|
||||
Ada.Text_Io.Put_Line("Resultat attendu : " & Attendu);
|
||||
Ada.Text_Io.Put_Line("Resultat obtenu : " & Obtenu);
|
||||
Ada.Text_Io.New_Line;
|
||||
end Afficher_Test;
|
|
@ -0,0 +1,72 @@
|
|||
package body Contacts is
|
||||
|
||||
function Initialiser_Contact(Nom, Prenom, Ville, Specialite, Telephone : in String) return Un_Contact is
|
||||
begin
|
||||
return (new String'(Nom), new String'(Prenom), new string'(Ville), new string'(Specialite), new string'(Telephone));
|
||||
end Initialiser_Contact;
|
||||
|
||||
function Nom(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Nom.all;
|
||||
end Nom;
|
||||
|
||||
function Prenom(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Prenom.all;
|
||||
end Prenom;
|
||||
|
||||
function Ville(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Ville.all;
|
||||
end Ville;
|
||||
|
||||
function Specialite(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Specialite.all;
|
||||
end Specialite;
|
||||
|
||||
function Telephone(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Telephone.all;
|
||||
end Telephone;
|
||||
|
||||
function Contact_To_String(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Nom.all & " " & C.Prenom.all & " " & C.Ville.all & " " & C.Specialite.all & " " & C.Telephone.all;
|
||||
end Contact_To_String;
|
||||
|
||||
function "="(C1, C2 : in Un_Contact) return Boolean is
|
||||
begin
|
||||
return C1.Nom.all = C2.Nom.all and C1.Prenom.all = C2.Prenom.all and C1.Ville.all = C2.Ville.all and C1.Specialite.all = C2.Specialite.all and C1.Telephone.all = C2.Telephone.all;
|
||||
end "=";
|
||||
|
||||
function "<"(C1, C2 : in Un_Contact) return Boolean is
|
||||
begin
|
||||
return C1.Nom.all < C2.Nom.all or else (C1.Nom.all = C2.Nom.all and C1.Prenom.all < C2.Prenom.all);
|
||||
end "<";
|
||||
|
||||
procedure Liberer_Contact(C : in out Un_Contact) is
|
||||
begin
|
||||
Liberer_String(C.Nom);
|
||||
Liberer_String(C.Prenom);
|
||||
Liberer_String(C.Ville);
|
||||
Liberer_String(C.Specialite);
|
||||
Liberer_String(C.Telephone);
|
||||
end Liberer_Contact;
|
||||
|
||||
function Slct_Spec(C : in Un_Contact) return Boolean is
|
||||
begin
|
||||
return C.Specialite.all = Choix;
|
||||
end Slct_Spec;
|
||||
|
||||
function Slct_Nom(C : in Un_Contact) return Boolean is
|
||||
begin
|
||||
return C.Nom.all = Choix;
|
||||
end Slct_Nom;
|
||||
|
||||
function Slct_Ville(C : in Un_Contact) return Boolean is
|
||||
begin
|
||||
return C.Ville.all = Choix;
|
||||
end Slct_Ville;
|
||||
|
||||
end Contacts;
|
|
@ -0,0 +1,51 @@
|
|||
with Pointeurs_De_Strings;
|
||||
use Pointeurs_De_Strings;
|
||||
|
||||
package Contacts is
|
||||
|
||||
type Un_Contact is private;
|
||||
|
||||
--constructeur
|
||||
function Initialiser_Contact(Nom, Prenom, Ville, Specialite, Telephone : in String) return Un_Contact;
|
||||
|
||||
--accesseurs
|
||||
function Nom(C : in Un_Contact) return String;
|
||||
function Prenom(C : in Un_Contact) return String;
|
||||
function Ville(C : in Un_Contact) return String;
|
||||
function Specialite(C : in Un_Contact) return String;
|
||||
function Telephone(C : in Un_Contact) return String;
|
||||
|
||||
--conversion en chaine
|
||||
function Contact_To_String(C : in Un_Contact) return String;
|
||||
|
||||
-- egalite
|
||||
function "="(C1, C2 : in Un_Contact) return Boolean;
|
||||
|
||||
--relation d'ordre
|
||||
function "<"(C1, C2 : in Un_Contact) return Boolean;
|
||||
|
||||
--recuperation memoire
|
||||
procedure Liberer_Contact(C : in out Un_Contact);
|
||||
|
||||
-- Fonction qui saura "regarder" au bon endroit selon ce qu'on demande
|
||||
generic
|
||||
Choix : String;
|
||||
function Slct_Spec(C : in Un_Contact) return Boolean;
|
||||
generic
|
||||
Choix : String;
|
||||
function Slct_Nom(C: in Un_Contact) return Boolean;
|
||||
generic
|
||||
Choix : String;
|
||||
function Slct_Ville(C: in Un_Contact) return Boolean;
|
||||
|
||||
private
|
||||
|
||||
type Un_Contact is record
|
||||
Nom : P_String;
|
||||
Prenom : P_String;
|
||||
Ville : P_String;
|
||||
Specialite : P_String;
|
||||
Telephone : P_String;
|
||||
end record;
|
||||
|
||||
end Contacts;
|
|
@ -0,0 +1,17 @@
|
|||
procedure Lire_Mot(S : String; Deb, Fin : out Integer) is
|
||||
-- cherche le debut et la fin du premier token
|
||||
-- si aucun token n'est trouve on aura en sortie : Deb > Fin
|
||||
begin
|
||||
Deb := S'First;
|
||||
Fin := Deb-1;
|
||||
while Deb <= S'last and then S(Deb) = ' ' loop
|
||||
Deb := Deb+1; --recherche du debut du 1er mot
|
||||
end loop;
|
||||
if Deb <= S'Last then
|
||||
Fin := Deb;
|
||||
while Fin <= S'Last and then S(Fin) /= ' ' loop
|
||||
Fin := Fin +1; --recherche de la fin du 1er mot
|
||||
end loop;
|
||||
Fin := Fin-1;
|
||||
end if;
|
||||
end Lire_Mot;
|
|
@ -0,0 +1,4 @@
|
|||
with Ada.Text_Io, listes_ordonnees_g, Contacts, Ada.Unchecked_Deallocation;
|
||||
use Contacts;
|
||||
|
||||
package Listes_Ordonnees_Contacts is new Listes_Ordonnees_G(Un_Contact,"<", Contact_To_string, Liberer_contact);
|
|
@ -0,0 +1,180 @@
|
|||
with Ada.Unchecked_Deallocation;
|
||||
|
||||
package body Listes_Ordonnees_g is
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
function Est_Vide(L : in Une_Liste_Ordonnee) return Boolean is
|
||||
begin
|
||||
return L.Debut = null;
|
||||
end Est_Vide;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
function Cardinal(L : in Une_Liste_Ordonnee) return Integer is
|
||||
begin
|
||||
return L.Taille;
|
||||
end Cardinal;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Appartient classique sur une liste simplement chainee (type Lien) ordonnee
|
||||
|
||||
function Appartient_Lien(E : Element; LL : in Lien) return Boolean is
|
||||
Resultat : boolean;
|
||||
begin
|
||||
if LL = null or else E < LL.all.info then
|
||||
Resultat := False; -- element non trouve
|
||||
elsif LL.all.Info = E then
|
||||
Resultat := True; -- element trouve en 1ere place
|
||||
else
|
||||
Resultat := Appartient_Lien(E, LL.all.Suiv); -- on cherche plus loin
|
||||
end if;
|
||||
return Resultat;
|
||||
end Appartient_Lien;
|
||||
|
||||
-- Appartient sur le type Une_Liste_Ordonnee_Entiers
|
||||
-- On reutilise la fonction classique Appartient_Lien sur L.debut
|
||||
function Appartient(E : in Element; L : in Une_Liste_Ordonnee) return Boolean is
|
||||
begin
|
||||
return Appartient_Lien(E, L.Debut);
|
||||
end Appartient;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-- Conversion en chaine de caracteres
|
||||
--
|
||||
-- sur le type Lien
|
||||
|
||||
function Lien_To_String(LL : in Lien) return String is
|
||||
begin
|
||||
if LL = null then return "";
|
||||
else return Image(LL.all.info) & Lien_To_String(LL.all.suiv);
|
||||
end if;
|
||||
end Lien_To_String;
|
||||
|
||||
-- sur le type Une_Liste_Ordonnee_Entiers
|
||||
function Liste_To_String(L: in Une_Liste_Ordonnee) return String is
|
||||
begin
|
||||
return Integer'Image(L.Taille) & " elements : (" & Lien_To_String(L.Debut) & " )";
|
||||
end Liste_To_String;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-- Insertion ORDONNEE et SANS DOUBLON
|
||||
|
||||
procedure Inserer_Lien(E: in Element; L: in out Lien) is
|
||||
begin
|
||||
if L = null then
|
||||
L := new Cellule'(E, null);
|
||||
elsif L.Info = E then raise Element_Deja_Present;
|
||||
elsif E < L.info then
|
||||
L := new Cellule'(E, L);
|
||||
else
|
||||
Inserer_Lien(E, L.Suiv);
|
||||
end if;
|
||||
|
||||
-- On desire une version RECURSIVE
|
||||
-- La procedure doit LEVER L'EXCEPTION Element_Deja_Present en
|
||||
-- cas de tentative d'insertion d'un doublon
|
||||
end Inserer_Lien;
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
procedure Inserer(E: in Element; L: in out Une_Liste_Ordonnee) is
|
||||
begin
|
||||
Inserer_Lien(E, L.Debut);
|
||||
L.Taille := L.Taille + 1;
|
||||
end Inserer;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
|
||||
-- Instanciation de Ada.Unchecked_Deallocation pour desallouer
|
||||
-- la memoire en cas de suppression des elements d'une liste
|
||||
-------------------------------------------------------------------------
|
||||
procedure Free is new Ada.Unchecked_Deallocation(Cellule, Lien);
|
||||
-------------------------------------------------------------------------
|
||||
procedure Supprimer_Lien(E : in Element; L: in out Lien) is
|
||||
Recup : Lien;
|
||||
begin
|
||||
if L = null or else E < L.All.Info then
|
||||
raise Element_Non_Present;
|
||||
elsif E = L.All.Info then
|
||||
Recup := L; -- on repere la cellule a recycler
|
||||
L := L.All.Suiv; -- on modifie le debut de la liste
|
||||
Free_Element(Recup.all.Info);
|
||||
Free(Recup); -- on recupere la memoire
|
||||
else
|
||||
Supprimer_Lien(E, L.all.suiv);
|
||||
end if;
|
||||
end Supprimer_Lien;
|
||||
-------------------------------------------------------------------------
|
||||
procedure Supprimer(E: in Element; L: in out Une_Liste_Ordonnee) is
|
||||
begin
|
||||
Supprimer_Lien(E, L.debut);
|
||||
L.Taille := L.Taille - 1;
|
||||
end Supprimer;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-- Fonctions facultatives
|
||||
function Egal_Lien(L1, L2 : in Lien) return Boolean is
|
||||
begin
|
||||
if L1 = null and L2 = null then
|
||||
return True;
|
||||
elsif (L1 = null or L2 = null) or (L1.Info /= L2.Info) then
|
||||
return False;
|
||||
elsif L1.Info = L2.Info then
|
||||
return Egal_Lien(L1.all.Suiv, L2.all.Suiv);
|
||||
else
|
||||
return FALSE; -- Ligne de code jamais atteinte, mais supprime des messages d'erreurs à la compilation.
|
||||
end if;
|
||||
end Egal_Lien;
|
||||
|
||||
function "="(L1, L2 : in Une_Liste_Ordonnee) return Boolean is
|
||||
begin
|
||||
return Egal_Lien(L1.Debut, L2.Debut);
|
||||
end "=";
|
||||
|
||||
procedure Copie_Lien_obsolete(L1: in Lien; L2 : out Lien) is
|
||||
P1 : Lien := L1;
|
||||
P2 : Lien := null;
|
||||
begin
|
||||
L2 := P2;
|
||||
if L1 /= null then
|
||||
P2 := new Cellule'(P1.all.Info, null);
|
||||
L2 := P2;
|
||||
P1 := P1.all.Suiv;
|
||||
while P1 /= null loop
|
||||
P2.all.Suiv := new Cellule'(P1.all.Info, null);
|
||||
P2 := P2.all.Suiv;
|
||||
P1 := P1.all.Suiv;
|
||||
end loop;
|
||||
end if;
|
||||
end Copie_Lien_Obsolete;
|
||||
|
||||
function Copie_Lien(L1: in Lien) return Lien is
|
||||
begin
|
||||
if L1 = null then return null;
|
||||
else return new Cellule'(L1.all.Info, Copie_Lien(L1.all.Suiv));
|
||||
end if;
|
||||
end Copie_Lien;
|
||||
|
||||
procedure Copie(L1 : in Une_Liste_Ordonnee; L2 : out Une_Liste_Ordonnee) is
|
||||
begin
|
||||
L2.Debut := Copie_lien(L1.Debut);
|
||||
L2.Taille := L1.Taille;
|
||||
end Copie;
|
||||
|
||||
procedure Filtrage(L: in out Une_Liste_Ordonnee) is
|
||||
P : Lien := L.Debut;
|
||||
begin
|
||||
while P /= null loop
|
||||
if not Critere(P.Info) then
|
||||
Supprimer(P.Info, L);
|
||||
end if;
|
||||
P := P.all.Suiv;
|
||||
end loop;
|
||||
end Filtrage;
|
||||
|
||||
end Listes_Ordonnees_g;
|
|
@ -0,0 +1,51 @@
|
|||
generic
|
||||
type Element is private;
|
||||
with function "<"(E1, E2: in Element) return Boolean;
|
||||
with function Image(E1 : in Element) return String;
|
||||
with procedure Free_Element(E : in out Element);
|
||||
|
||||
package Listes_Ordonnees_g is
|
||||
|
||||
type Une_Liste_Ordonnee is limited private;
|
||||
|
||||
Element_Non_Present, Element_Deja_Present : exception;
|
||||
|
||||
function Est_Vide(L : in Une_Liste_Ordonnee) return Boolean;
|
||||
|
||||
function Cardinal(L : in Une_Liste_Ordonnee) return Integer;
|
||||
|
||||
function Appartient(E : in Element; L : in Une_Liste_Ordonnee) return Boolean;
|
||||
|
||||
procedure Inserer(E: in Element; L: in out Une_Liste_Ordonnee);
|
||||
|
||||
procedure Supprimer(E: in Element; L: in out Une_Liste_Ordonnee);
|
||||
|
||||
function Liste_To_String(L: in Une_Liste_Ordonnee) return String;
|
||||
|
||||
--ajouts de ss-programmes d'egalite et de copie
|
||||
function "="(L1, L2 : in Une_Liste_Ordonnee) return Boolean;
|
||||
|
||||
procedure Copie(L1 : in Une_Liste_Ordonnee; L2 : out Une_Liste_Ordonnee);
|
||||
|
||||
generic
|
||||
with function Critere(E: in Element) return Boolean;
|
||||
procedure Filtrage(L: in out Une_Liste_Ordonnee);
|
||||
|
||||
|
||||
private
|
||||
-- types classiques permettant de realiser des listes simplement chainees
|
||||
type Cellule;
|
||||
type Lien is access Cellule;
|
||||
type Cellule is record
|
||||
Info : Element;
|
||||
Suiv : Lien;
|
||||
end record;
|
||||
|
||||
-- type liste ameliore : record contenant la liste et sa taille
|
||||
-- (evite de parcourir la liste pour calculer la taille)
|
||||
|
||||
type Une_Liste_Ordonnee is record
|
||||
Debut : Lien := null;
|
||||
Taille : Natural := 0;
|
||||
end record;
|
||||
end Listes_Ordonnees_g;
|
|
@ -0,0 +1,9 @@
|
|||
with Ada.Unchecked_Deallocation;
|
||||
|
||||
package Pointeurs_De_Strings is
|
||||
|
||||
type P_String is access String;
|
||||
|
||||
procedure Liberer_String is new Ada.Unchecked_Deallocation(String , P_String);
|
||||
|
||||
end Pointeurs_De_Strings;
|
未顯示二進位檔案。
|
@ -0,0 +1,274 @@
|
|||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
with Ada.IO_Exceptions;
|
||||
with Contacts; use Contacts;
|
||||
with Afficher_Test;
|
||||
with Listes_Ordonnees_Contacts; use Listes_Ordonnees_Contacts;
|
||||
|
||||
procedure Tester_Liste_Contacts is
|
||||
|
||||
function Critere(C: in Un_Contact) return Boolean is
|
||||
begin
|
||||
return Ville(C) = "Beauvais";
|
||||
end Critere;
|
||||
|
||||
procedure Filtre is new Filtrage(Critere);
|
||||
|
||||
Fichier : File_Type;
|
||||
Chaine, Ligne, crit : String(1..80);
|
||||
Len, last : Integer := 0;
|
||||
L_ann : Une_Liste_Ordonnee;
|
||||
C : Un_Contact;
|
||||
|
||||
Rep : Character;
|
||||
Prenom, Nom, Ville, Specia, Telephone, Fin, I : Integer := 0;
|
||||
begin
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Utilisation d'annuaires
|
||||
-----------------------------------------------------------
|
||||
|
||||
-- Entourloupe pour avoir un nom de fichier contraint, saisi par l'utilisateur et de bonne taille
|
||||
Put_Line("Lecture d'un fichier de contact, veillez saisir le nom du fichier : ");
|
||||
Get_Line(Chaine, Len);
|
||||
declare
|
||||
Nom_Fichier : String(Chaine'First..Len) := Chaine(Chaine'First..Len);
|
||||
begin
|
||||
open(Fichier, in_File, Nom_Fichier);
|
||||
while not End_Of_File(Fichier) loop
|
||||
Get_Line (Fichier, Ligne , Len ) ;
|
||||
Put_Line ( "Ajouté à l'annuaire: " & Ligne(1..Len));
|
||||
|
||||
Prenom := 1;
|
||||
Nom := 0;
|
||||
Ville := 0;
|
||||
Specia := 0;
|
||||
Telephone := 0;
|
||||
Fin := 0;
|
||||
I := 1;
|
||||
|
||||
while Telephone = 0 loop
|
||||
if Ligne(I) = ' ' then
|
||||
if Nom = 0 then Nom := I;
|
||||
elsif Ville = 0 then Ville := I;
|
||||
elsif Specia = 0 then Specia := I;
|
||||
elsif Telephone = 0 then Telephone := I; Fin := Telephone + 10;
|
||||
end if;
|
||||
end if;
|
||||
I := I + 1;
|
||||
end loop;
|
||||
C := Initialiser_Contact(Ligne(Prenom..Nom-1), Ligne(Nom+1..Ville-1), Ligne(Ville+1..Specia-1), Ligne(Specia+1..Telephone-1), Ligne(Telephone+1..Fin-1) & " ");
|
||||
Inserer(C, L_Ann);
|
||||
end loop;
|
||||
Close(Fichier);
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test sur annuaire
|
||||
-----------------------------------------------------------
|
||||
New_Line;
|
||||
Put_Line("Test sur l'annuaire fournis");
|
||||
|
||||
Afficher_Test("Est_Vide() ?", "Inconnu", Boolean'Image(Est_Vide(L_ann)));
|
||||
Afficher_Test("Cardinal() ?", "Inconnu", Integer'Image(Cardinal(L_ann)));
|
||||
|
||||
Put_Line("Vous avez saisi l'annuaire suivant : ");
|
||||
Put_Line(Liste_To_String(L_ann)); New_Line;
|
||||
|
||||
Put_Line("Test de filtrage : ");
|
||||
Filtre(L_Ann);
|
||||
Put_Line("...filtrée :");
|
||||
Put_Line(Liste_To_String(L_ann)); New_Line;
|
||||
|
||||
----------------------------------------------------------
|
||||
|
||||
-- Choix Utilisateur à partir des fonctions génériques
|
||||
Put_line("Choix: Nom(0), Ville(1), Specialite(2) ");
|
||||
Get(Rep); Skip_Line;
|
||||
|
||||
case Rep is
|
||||
when '0' =>
|
||||
Put_Line("Valeur du nom recherche : ");
|
||||
Get_Line(Crit, Last);
|
||||
declare
|
||||
function Selection_Nom is new Slct_Nom(Crit(1..Last));
|
||||
procedure FiltrerNom is new Filtrage(Selection_Nom);
|
||||
begin
|
||||
FiltrerNom(L_ann);
|
||||
Put_Line("Liste de contacts filtres : ");
|
||||
Put(Liste_To_String(L_ann));
|
||||
end;
|
||||
|
||||
when '1' =>
|
||||
Put_Line("Valeur de la ville recherchee : ");
|
||||
Get_Line(Crit, Last);
|
||||
declare
|
||||
function Selection_Ville is new Slct_Ville(Crit(1..Last));
|
||||
procedure FiltrerVille is new Filtrage(Selection_Ville);
|
||||
begin
|
||||
FiltrerVille(L_ann);
|
||||
Put_Line("Liste de contacts filtres : ");
|
||||
Put(Liste_To_String(L_ann));
|
||||
end;
|
||||
|
||||
when '2' =>
|
||||
Put_Line("Valeur de la specialite recherchee : ");
|
||||
Get_Line(Crit, Last);
|
||||
|
||||
declare
|
||||
function Selection_Specialite is new Slct_Spec(Crit(1..Last));
|
||||
procedure FiltrerSpecialite is new Filtrage(Selection_Specialite);
|
||||
begin
|
||||
FiltrerSpecialite(L_ann);
|
||||
Put_Line("Liste de contacts filtres : ");
|
||||
Put(Liste_To_String(L_ann));
|
||||
end;
|
||||
when others => null;
|
||||
end case;
|
||||
|
||||
----------------------------------------------------------
|
||||
|
||||
New_Line;
|
||||
Put_Line("---------------------------");
|
||||
Put_Line("FIN DES TESTS AVEC ANNUAIRE");
|
||||
Put_Line("---------------------------");
|
||||
New_Line;
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test de création
|
||||
-----------------------------------------------------------
|
||||
Put_Line("Test après création");
|
||||
declare
|
||||
L : Une_Liste_Ordonnee;
|
||||
begin
|
||||
Afficher_Test("Est_Vide() ?", "TRUE", Boolean'Image(Est_Vide(L)));
|
||||
Afficher_Test("Cardinal() ?", "0", Integer'Image(Cardinal(L)));
|
||||
|
||||
Put_Line("Test d'affichage: ");
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test d'ajout d'éléments
|
||||
-----------------------------------------------------------
|
||||
Put_Line("Test après ajout d'éléments");
|
||||
declare
|
||||
L : Une_Liste_Ordonnee;
|
||||
C1 : Un_Contact := Initialiser_Contact("Charles", "Chang", "Beziers", "ORL", "0703888032");
|
||||
C2 : Un_Contact := Initialiser_Contact("Martha", "Bibbs", "Beauvais", "Psychiatre", "0616751216");
|
||||
C3 : Un_Contact := Initialiser_Contact("Jerry", "Joosten", "Albi", "Pharmacien", "0724258260");
|
||||
C4 : Un_Contact := Initialiser_Contact("Elijah", "Taylor", "Caen", "Orthodontiste", "0770222606");
|
||||
begin
|
||||
Put_Line("Liste créée, on ajout des éléments");
|
||||
Inserer(C1,L);
|
||||
Inserer(C2,L);
|
||||
Inserer(C3,L);
|
||||
Inserer(C4,L);
|
||||
Put_Line("4 éléments ajoutés");
|
||||
|
||||
Put_Line("Test d'affichage: ");
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
|
||||
Afficher_Test("Est_Vide() ?", "FALSE", Boolean'Image(Est_Vide(L)));
|
||||
Afficher_Test("Cardinal() ?", "4", Integer'Image(Cardinal(L)));
|
||||
Afficher_Test("Appartient(C2) ?", "TRUE", Boolean'Image(Appartient(C2,L)));
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test de manipulation
|
||||
-----------------------------------------------------------
|
||||
Put_Line("Test de manipulation");
|
||||
declare
|
||||
L : Une_Liste_Ordonnee;
|
||||
C1 : Un_Contact := Initialiser_Contact("Charles", "Chang", "Beziers", "ORL", "0703888032");
|
||||
C2 : Un_Contact := Initialiser_Contact("Martha", "Bibbs", "Beauvais", "Psychiatre", "0616751216");
|
||||
C3 : Un_Contact := Initialiser_Contact("Jerry", "Joosten", "Albi", "Pharmacien", "0724258260");
|
||||
C4 : Un_Contact := Initialiser_Contact("Elijah", "Taylor", "Caen", "Orthodontiste", "0770222606");
|
||||
begin
|
||||
Put_Line("Liste créée, on ajout des éléments");
|
||||
Inserer(C1,L);
|
||||
Inserer(C2,L);
|
||||
Inserer(C3,L);
|
||||
Inserer(C4,L);
|
||||
Put_Line("Liste créée, 4 éléments ajoutés");
|
||||
Put_Line("Liste: ");
|
||||
Put_Line("On supprime C2:"); Supprimer(C2,L);
|
||||
Afficher_Test("Cardinal() ?", "3", Integer'Image(Cardinal(L)));
|
||||
Afficher_Test("Appartient(C2) ?", "FALSE", Boolean'Image(Appartient(C2,L)));
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test d'exceptions
|
||||
-----------------------------------------------------------
|
||||
declare
|
||||
L : Une_Liste_Ordonnee;
|
||||
C1 : Un_Contact := Initialiser_Contact("Charles", "Chang", "Beziers", "ORL", "0703888032");
|
||||
C2 : Un_Contact := Initialiser_Contact("Martha", "Bibbs", "Beauvais", "Psychiatre", "0616751216");
|
||||
C3 : Un_Contact := Initialiser_Contact("Jerry", "Joosten", "Albi", "Pharmacien", "0724258260");
|
||||
C4 : Un_Contact := Initialiser_Contact("Elijah", "Taylor", "Caen", "Orthodontiste", "0770222606");
|
||||
begin
|
||||
Put_Line("Liste créée, on ajout des éléments");
|
||||
Inserer(C1,L);
|
||||
Inserer(C2,L);
|
||||
Inserer(C3,L);
|
||||
Put_Line("On supprime un élément inexistant : ");
|
||||
Supprimer(C4, L);
|
||||
exception
|
||||
when Element_Non_Present => Put_Line("L'exception Element_Non_Present est correctement levée !");
|
||||
end;
|
||||
declare
|
||||
L : Une_Liste_Ordonnee;
|
||||
C1 : Un_Contact := Initialiser_Contact("Charles", "Chang", "Beziers", "ORL", "0703888032");
|
||||
C2 : Un_Contact := Initialiser_Contact("Martha", "Bibbs", "Beauvais", "Psychiatre", "0616751216");
|
||||
C3 : Un_Contact := Initialiser_Contact("Jerry", "Joosten", "Albi", "Pharmacien", "0724258260");
|
||||
C4 : Un_Contact := Initialiser_Contact("Elijah", "Taylor", "Caen", "Orthodontiste", "0770222606");
|
||||
begin
|
||||
Put_Line("Liste créée, on ajout des éléments");
|
||||
Inserer(C1,L);
|
||||
Inserer(C2,L);
|
||||
Put_Line("On ajoute un élément déjà présent : ");
|
||||
Inserer(C2, L);
|
||||
exception
|
||||
when Element_Deja_Present => Put_Line("L'exception Element_Deja_Present est correctement levée !");
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test des fonctions auxiliaires
|
||||
-----------------------------------------------------------
|
||||
declare
|
||||
L, L2 : Une_Liste_Ordonnee;
|
||||
C1 : Un_Contact := Initialiser_Contact("Charles", "Chang", "Beziers", "ORL", "0703888032");
|
||||
C2 : Un_Contact := Initialiser_Contact("Martha", "Bibbs", "Beauvais", "Psychiatre", "0616751216");
|
||||
C3 : Un_Contact := Initialiser_Contact("Jerry", "Joosten", "Albi", "Pharmacien", "0724258260");
|
||||
C4 : Un_Contact := Initialiser_Contact("Elijah", "Taylor", "Caen", "Orthodontiste", "0770222606");
|
||||
begin
|
||||
New_Line;
|
||||
Put_Line("Test des fonctions auxilaires (=)");
|
||||
Put_Line("Liste créée, on ajout des éléments");
|
||||
Inserer(C1,L);
|
||||
Inserer(C2,L);
|
||||
Inserer(C3,L);
|
||||
Inserer(C4,L);
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
Put_Line("On en créé une copie L2: ");
|
||||
Copie(L, L2);
|
||||
Put_Line(Liste_To_String(L2)); New_Line;
|
||||
|
||||
Put_Line("On vérifie qu'elles sont égales:");
|
||||
Afficher_Test("=(L,L2) ?", "TRUE", Boolean'Image(L=L2));
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
New_Line;
|
||||
Put_Line("Fin des tests.");
|
||||
exception
|
||||
when ADA.IO_EXCEPTIONS.NAME_ERROR => Put_Line("Fichier invalide.");
|
||||
end;
|
||||
end Tester_Liste_Contacts;
|
未顯示二進位檔案。
|
@ -0,0 +1,117 @@
|
|||
with Ada.Text_Io, listes_ordonnees_g, Afficher_Test, Ada.Unchecked_Deallocation;
|
||||
use Ada.Text_Io;
|
||||
|
||||
procedure Tester_Liste_Ordonnee_Entiers is
|
||||
procedure Free_Null(I: in Integer) is
|
||||
begin
|
||||
null;
|
||||
end Free_Null;
|
||||
|
||||
package Listes_Entiers is new Listes_Ordonnees_G(Integer,"<", Integer'Image, Free_Null);
|
||||
use Listes_Entiers;
|
||||
begin
|
||||
-----------------------------------------------------------
|
||||
-- Test de création
|
||||
-----------------------------------------------------------
|
||||
Put_Line("Test après création");
|
||||
declare
|
||||
L : Une_Liste_Ordonnee;
|
||||
begin
|
||||
Afficher_Test("Est_Vide() ?", "TRUE", Boolean'Image(Est_Vide(L)));
|
||||
Afficher_Test("Cardinal() ?", "0", Integer'Image(Cardinal(L)));
|
||||
|
||||
Put_Line("Test d'affichage: ");
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test d'ajout d'éléments
|
||||
-----------------------------------------------------------
|
||||
Put_Line("Test après ajout d'éléments");
|
||||
declare
|
||||
L : Une_Liste_Ordonnee;
|
||||
begin
|
||||
Put_Line("Liste créée, on ajout des éléments");
|
||||
Inserer(1,L);
|
||||
Inserer(-1,L);
|
||||
Inserer(3,L);
|
||||
Inserer(45,L);
|
||||
Inserer(2,L);
|
||||
Inserer(9,L);
|
||||
Put_Line("6 éléments ajoutés : [1, -1, 3, 45, 2, 9].");
|
||||
|
||||
Put_Line("Test d'affichage: ");
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
|
||||
Afficher_Test("Est_Vide() ?", "FALSE", Boolean'Image(Est_Vide(L)));
|
||||
Afficher_Test("Cardinal() ?", "6", Integer'Image(Cardinal(L)));
|
||||
Afficher_Test("Appartient(2) ?", "TRUE", Boolean'Image(Appartient(2,L)));
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test de manipulation
|
||||
-----------------------------------------------------------
|
||||
Put_Line("Test de manipulation");
|
||||
declare
|
||||
L : Une_Liste_Ordonnee;
|
||||
begin
|
||||
Inserer(1,L); Inserer(-1,L);Inserer(3,L);Inserer(45,L);Inserer(2,L);Inserer(9,L);
|
||||
Put_Line("Liste créée, 6 éléments ajoutés : [1, -1, 3, 45, 2, 9].");
|
||||
Put_Line("Liste: ");
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
Put_Line("On supprime 2:"); Supprimer(2,L);
|
||||
Afficher_Test("Cardinal() ?", "5", Integer'Image(Cardinal(L)));
|
||||
Afficher_Test("Appartient(2) ?", "FALSE", Boolean'Image(Appartient(2,L)));
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test d'exceptions
|
||||
-----------------------------------------------------------
|
||||
declare
|
||||
L : Une_Liste_Ordonnee;
|
||||
begin
|
||||
Inserer(1,L); Inserer(-1,L);Inserer(3,L);
|
||||
Put_Line("On supprime un élément inexistant : ");
|
||||
Supprimer(28, L);
|
||||
exception
|
||||
when Element_Non_Present => Put_Line("L'exception Element_Non_Present est correctement levée !");
|
||||
end;
|
||||
declare
|
||||
L : Une_Liste_Ordonnee;
|
||||
begin
|
||||
Inserer(1,L); Inserer(-1,L);Inserer(3,L);
|
||||
Put_Line("On ajoute un élément déjà présent : ");
|
||||
Inserer(1, L);
|
||||
exception
|
||||
when Element_Deja_Present => Put_Line("L'exception Element_Deja_Present est correctement levée !");
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Test des fonctions auxiliaires
|
||||
-----------------------------------------------------------
|
||||
declare
|
||||
L, L2 : Une_Liste_Ordonnee;
|
||||
begin
|
||||
Put_Line("On créé une liste L: ");
|
||||
Inserer(1,L); Inserer(-1,L);Inserer(3,L);
|
||||
Put_Line(Liste_To_String(L)); New_Line;
|
||||
Put_Line("On en créé une copie L2: ");
|
||||
Copie(L, L2);
|
||||
Put_Line(Liste_To_String(L2)); New_Line;
|
||||
|
||||
Put_Line("On vérifie qu'elles sont égales:");
|
||||
Afficher_Test("=(L,L2) ?", "TRUE", Boolean'Image(L=L2));
|
||||
end;
|
||||
-----------------------------------------------------------
|
||||
|
||||
New_Line;
|
||||
Put_Line("Fin des tests.");
|
||||
end Tester_Liste_Ordonnee_Entiers;
|
|
@ -0,0 +1,11 @@
|
|||
with Ada.Text_Io;
|
||||
|
||||
procedure Afficher_Test(Txt_Appel, Txt_Attendu, Txt_Obtenu : in String) is
|
||||
begin
|
||||
Ada.Text_Io.New_Line;
|
||||
Ada.Text_Io.Put_Line("-----------------------------------------------------------");
|
||||
Ada.Text_Io.Put_Line(Txt_Appel);
|
||||
Ada.Text_Io.Put_Line("Attendu : " & Txt_Attendu);
|
||||
Ada.Text_Io.Put_Line("Obtenu : " & Txt_Obtenu);
|
||||
Ada.Text_Io.New_Line;
|
||||
end Afficher_Test;
|
|
@ -0,0 +1 @@
|
|||
procedure Afficher_Test(Txt_Appel, Txt_Attendu, Txt_Obtenu : in string);
|
|
@ -0,0 +1,226 @@
|
|||
-- Date : Mars 2015
|
||||
-- Auteur : MJ. Huguet
|
||||
--
|
||||
-- Objet : corps paquetage arbre binaire de recherche generique
|
||||
--
|
||||
-- Fait
|
||||
--
|
||||
-----------------------------------------------------------------------------
|
||||
with Unchecked_Deallocation;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
package body Arbre_Bin_Recherche_Cle_G is
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
procedure Free_Noeud IS NEW Unchecked_Deallocation(Noeud, LienArbre);
|
||||
|
||||
procedure Liberer_Lien(LA : in out LienArbre) is
|
||||
begin
|
||||
if LA /= null then
|
||||
Liberer_Lien(LA.all.gauche); -- desallocation partie gauche
|
||||
Liberer_Lien(LA.all.droite); -- desallocation partie droite
|
||||
Liberer_Element(LA.All.Info); -- desallocation contenu du noeud racine
|
||||
Free_Noeud(LA); -- desallocation noeud racine
|
||||
end if;
|
||||
end Liberer_Lien;
|
||||
|
||||
procedure Liberer(A : in out Arbre) is
|
||||
begin
|
||||
Liberer_Lien(A.Debut);
|
||||
A.Debut := null;
|
||||
A.Taille := 0;
|
||||
end Liberer;
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
function ">"(K1, K2 : Key) return Boolean is begin
|
||||
return K2 < K1; end ">";
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
function Est_Vide(A : in Arbre) return Boolean is
|
||||
begin
|
||||
return A.Debut=null;
|
||||
end Est_Vide;
|
||||
-----------------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------------
|
||||
function Taille(A : in Arbre) return Natural is
|
||||
begin
|
||||
return A.Taille;
|
||||
end Taille;
|
||||
-----------------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------------
|
||||
function Racine(A: in Arbre) return Element is
|
||||
begin
|
||||
if Est_Vide(A) then
|
||||
raise Arbre_Vide;
|
||||
else
|
||||
return A.Debut.all.Info;
|
||||
end if;
|
||||
end Racine;
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
function Appartient_Lien(E : in Element; LA : in LienArbre) return Boolean is
|
||||
-- Fait
|
||||
begin
|
||||
if LA = null then
|
||||
return False;
|
||||
elsif Cle_de(LA.Info) > Cle_de(E) then
|
||||
return Appartient_Lien(E, LA.Gauche);
|
||||
elsif Cle_de(LA.Info) < Cle_De(E) then
|
||||
return Appartient_Lien(E, LA.Droite);
|
||||
else
|
||||
return TRUE;
|
||||
end if;
|
||||
end Appartient_Lien;
|
||||
|
||||
function Appartient(E : in Element; A : in Arbre) return Boolean is
|
||||
begin
|
||||
return Appartient_Lien(E, A.Debut);
|
||||
end Appartient;
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
function Lien_To_String(LA : in LienArbre) return String is
|
||||
-- Fait
|
||||
begin
|
||||
if LA /= null then
|
||||
return Lien_To_String(LA.Gauche) & Element_To_String(LA.Info) & Lien_To_String(LA.Droite);
|
||||
else return "";
|
||||
end if;
|
||||
end Lien_To_String;
|
||||
|
||||
function Arbre_To_String(A : in Arbre) return String is
|
||||
begin
|
||||
return "(" & Integer'Image(A.Taille) & "|" & Lien_To_String(A.Debut) & ")";
|
||||
end Arbre_To_String;
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Fait en version itérative comme demandé, moins efficace que la version récursive
|
||||
procedure Inserer_Lien(E : in Element; LA : in out LienArbre) is
|
||||
-- Fait
|
||||
P, Prec : LienArbre := LA;
|
||||
begin
|
||||
if LA = null then -- Si l'arbre est vide, on ajoute un premier noeud
|
||||
LA := new Noeud'(E, null, null);
|
||||
else -- Sinon on parcourt l'arbre en fonction de la valeur
|
||||
while P /= null loop -- de E jusqu'à une case où l'on peut l'ajouter
|
||||
if Cle_De(E) > Cle_De(P.Info) then
|
||||
Prec := P; -- On mémorise la valeur du précédant à P également
|
||||
P := P.all.Droite;
|
||||
elsif Cle_De(E) < Cle_De(P.Info) then
|
||||
Prec := P;
|
||||
P := P.all.Gauche;
|
||||
else
|
||||
raise Element_Deja_Present;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
if Prec.Gauche = null and then Cle_De(Prec.Info) > Cle_De(E) then
|
||||
Prec.Gauche := new Noeud'(E, null, null);
|
||||
elsif Prec.Droite = null and then Cle_De(Prec.Info) < Cle_De(E) then
|
||||
Prec.Droite := new Noeud'(E, null, null);
|
||||
else
|
||||
raise Program_Error;
|
||||
end if;
|
||||
end if;
|
||||
end Inserer_Lien;
|
||||
|
||||
procedure Inserer(E : Element; A : in out Arbre) is
|
||||
begin
|
||||
Inserer_Lien(E, A.Debut);
|
||||
A.Taille := A.Taille + 1;
|
||||
end Inserer;
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
procedure Supprimer_Maxg(LA : in out LienArbre; Maxg : out Element) is
|
||||
-- Fait
|
||||
Buffer : LienArbre;
|
||||
begin
|
||||
if LA.Droite = null then
|
||||
Maxg := LA.Info;
|
||||
|
||||
Buffer := LA.Gauche; -- Ces "tas" d'instructions (plusieurs arrivent
|
||||
LA.info := LA.Gauche.info; -- ensuite) sont dû au fait qu'implémenter une
|
||||
LA.Droite := LA.Gauche.Droite; -- fonction de copie valables dans tous les cas
|
||||
LA.Gauche := LA.Gauche.Gauche; -- serait ajouter une compléxité non nécéssaire
|
||||
|
||||
Liberer_Element(Buffer.Info);
|
||||
Free_Noeud(Buffer);
|
||||
else
|
||||
Supprimer_Maxg(LA.Droite, Maxg);
|
||||
end if;
|
||||
end Supprimer_Maxg;
|
||||
|
||||
procedure Supprimer_Lien(E : in Element; LA : in out LienArbre ) is
|
||||
-- Fait (cf. page 41 poly)
|
||||
Maxg : Element;
|
||||
Buffer : LienArbre;
|
||||
begin
|
||||
if LA = null then raise Element_Non_Present;
|
||||
elsif Cle_De(E) > Cle_De(LA.Info) then -- On cherche le lien supprimer
|
||||
Supprimer_Lien(E, LA.all.Droite); -- en récursif
|
||||
elsif Cle_De(E) < Cle_De(LA.Info) then
|
||||
Supprimer_Lien(E, LA.all.Gauche);
|
||||
else -- i.e. E = LA.info
|
||||
if LA.Droite = null and LA.Gauche = null then
|
||||
Maxg := LA.Info;
|
||||
Liberer_Lien(LA);
|
||||
LA := null;
|
||||
elsif LA.Droite = null then -- Pour des raisons techniques, il est
|
||||
Buffer := LA.Gauche; -- préférable de "vampiriser" le noeud
|
||||
LA.info := LA.Gauche.info; -- fils
|
||||
LA.Droite := LA.Gauche.Droite;
|
||||
LA.Gauche := LA.Gauche.Gauche;
|
||||
|
||||
Liberer_Element(Buffer.Info);
|
||||
Free_Noeud(Buffer);
|
||||
elsif LA.Gauche = null then -- Idem
|
||||
Buffer := LA.Droite;
|
||||
LA.Info := LA.Droite.Info;
|
||||
LA.Gauche := LA.Droite.Gauche;
|
||||
LA.Droite := LA.Droite.Droite;
|
||||
|
||||
Liberer_Element(Buffer.Info);
|
||||
Free_Noeud(Buffer);
|
||||
else -- Ou on le remplace par une valeur
|
||||
Supprimer_Maxg(LA.Gauche, Maxg);
|
||||
LA.Info := Maxg;
|
||||
end if;
|
||||
end if;
|
||||
end Supprimer_Lien;
|
||||
|
||||
|
||||
procedure Supprimer(E : in Element; A : in out Arbre) is
|
||||
begin
|
||||
Supprimer_Lien(E, A.Debut);
|
||||
A.Taille := A.Taille - 1;
|
||||
end Supprimer;
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
function Recherche_Lien(C: in Key; LA : in LienArbre) return Element is
|
||||
begin
|
||||
if LA = null then raise Element_Non_Present;
|
||||
elsif Cle_De(LA.Info) > C then
|
||||
return Recherche_Lien(C, LA.Gauche);
|
||||
elsif Cle_De(LA.Info) < C then
|
||||
return Recherche_Lien(C, LA.Droite);
|
||||
else
|
||||
return LA.Info;
|
||||
end if;
|
||||
end Recherche_Lien;
|
||||
|
||||
function Rechercher_Par_Cle(C: in Key; A : in Arbre) return Element is
|
||||
begin
|
||||
return Recherche_Lien(C, A.Debut);
|
||||
end Rechercher_Par_Cle;
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
end Arbre_Bin_Recherche_Cle_G;
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
-- Date : Mars 2015
|
||||
-- Auteur : MJ. Huguet
|
||||
--
|
||||
-- Objet : specification arbre binaire de recherche generique
|
||||
--
|
||||
-- Remarque :
|
||||
-- les elements disposent d'une cle permettant de les identifier
|
||||
-----------------------------------------------------------------------------
|
||||
generic
|
||||
type Element is private;
|
||||
type Key is private;
|
||||
with function Cle_De(E : in Element) return Key;
|
||||
with function "<"(C1, C2 : in Key) return Boolean;
|
||||
with function "="(C1, C2 : in Key) return Boolean;
|
||||
with procedure Liberer_Element(E : in out Element);
|
||||
with function Element_To_String(E : in Element) return String;
|
||||
package Arbre_Bin_Recherche_Cle_G is
|
||||
Element_Deja_Present, Element_Non_Present, Arbre_Vide : exception;
|
||||
|
||||
type Arbre is limited private; -- A la declaration un arbre est initialise (arbre vide)
|
||||
|
||||
procedure Liberer(A : in out Arbre);
|
||||
function Est_Vide(A : in Arbre) return Boolean;
|
||||
function Taille(A : in Arbre) return Natural;
|
||||
function Racine(A: in Arbre) return Element; -- peut lever l'exception Arbre_Vide
|
||||
|
||||
-- function Appartient(E : in Element; A : in Arbre) return Boolean;
|
||||
function Appartient(E : in Element; A : in Arbre) return Boolean;
|
||||
|
||||
-- Chaine correspondant a un parcours infixe (Gauche-Racine-Droite)
|
||||
function Arbre_To_String(A : in Arbre) return string;
|
||||
|
||||
procedure Inserer(E: in Element; A: in out Arbre ); -- peut lever l'exception Element_Deja_Present
|
||||
procedure Supprimer(E : in Element; A : in out Arbre); -- peut lever l'exception Element_Non_Present
|
||||
|
||||
|
||||
function Rechercher_Par_Cle(C: in Key; A : in Arbre) return Element;
|
||||
|
||||
|
||||
|
||||
|
||||
--function Sous_Arbre_Gauche(A : in Arbre) return Arbre;
|
||||
--function Sous_Arbre_Droit(A : in Arbre) return Arbre;
|
||||
|
||||
-- parcourir infixe
|
||||
--generic
|
||||
-- with procedure Traiter(E : in Element);
|
||||
--procedure Parcourir_GRD(A : in Arbre);
|
||||
|
||||
--procedure Impression_Couchee(A : in Arbre; Decalage : in String:= "");
|
||||
|
||||
|
||||
-- Tab_Recherche : ARRAY(1..2) OF Natural := (0, 0);
|
||||
-- Tab_Resu(1) ==> nb test
|
||||
-- Tab_Resu(2) ==> nb parcours
|
||||
-- Tab_Recherche_Ordre : ARRAY(1..2) OF Natural := (0, 0);
|
||||
-- Tab_Resu(1) ==> nb test
|
||||
-- Tab_Resu(2) ==> nb parcours
|
||||
|
||||
|
||||
-- Fonction permettant de rechercher dans la liste les elements verifiant
|
||||
-- certaines proprietes (exprimees dans Filtrer)
|
||||
--generic
|
||||
-- with function Filtrer(E1, E2 : in Element) return boolean;
|
||||
--function Rechercher(E : in Element; A : in Arbre) return Arbre;
|
||||
|
||||
-- Fonction permettant de rechercher dans la liste les elements verifiant
|
||||
-- certaines proprietes (exprimees dans Filtrer) et avec des conditions
|
||||
-- d'arrêt de la recherche
|
||||
--generic
|
||||
-- with function Filtrer(E1, E2 : in Element) return Boolean;
|
||||
-- with function Direction_Filtrer(E1, E2 : in Element) return Boolean;
|
||||
--function Rechercher_Ordre(E : in Element; A : in Arbre) return Arbre;
|
||||
|
||||
|
||||
private
|
||||
type Noeud;
|
||||
|
||||
type LienArbre is access Noeud;
|
||||
type Noeud is record
|
||||
Info : Element;
|
||||
Gauche : LienArbre;
|
||||
Droite : LienArbre;
|
||||
end record;
|
||||
|
||||
type Arbre is record
|
||||
Debut : LienArbre := null;
|
||||
Taille : natural := 0;
|
||||
end record;
|
||||
|
||||
END Arbre_Bin_Recherche_Cle_g;
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
-- Date : Mars 2015
|
||||
-- Auteur : MJ. Huguet
|
||||
--
|
||||
-- Objet : corps du paquetage Contact (avec cle)
|
||||
--
|
||||
-----------------------------------------------------------------------------
|
||||
package body Contact_Cle is
|
||||
|
||||
function Creer_Contact(Nom, Prenom, Ville, Specialite, Telephone : in String) return Un_Contact is
|
||||
begin
|
||||
return (new String'(Nom), new String'(Prenom), new string'(Ville), new string'(Specialite), Telephone);
|
||||
end Creer_Contact;
|
||||
|
||||
function Nom(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Nom.all;
|
||||
end Nom;
|
||||
|
||||
function Prenom(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Prenom.all;
|
||||
end Prenom;
|
||||
|
||||
function Ville(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Ville.all;
|
||||
end Ville;
|
||||
|
||||
function Specialite(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Specialite.all;
|
||||
end Specialite;
|
||||
|
||||
function Telephone(C : in Un_Contact) return Cle_Contact is
|
||||
begin
|
||||
return C.Telephone;
|
||||
end Telephone;
|
||||
|
||||
function Contact_To_String(C : in Un_Contact) return String is
|
||||
begin
|
||||
return C.Nom.all & " " & C.Prenom.all & " " & C.Ville.all & " " & C.Specialite.all & " " & C.Telephone & "; ";
|
||||
end Contact_To_String;
|
||||
|
||||
|
||||
function Cle(C : in Un_Contact) return Cle_Contact is
|
||||
begin
|
||||
return C.Telephone;
|
||||
end Cle;
|
||||
|
||||
function "="(S1, S2 : in Cle_Contact) return Boolean is
|
||||
Res : Boolean := True;
|
||||
indice : Integer := S1'First;
|
||||
begin
|
||||
while Indice <= S1'Last and Res=True loop
|
||||
if S1(Indice) /= S2(Indice) then
|
||||
Indice := Indice+1;
|
||||
else
|
||||
Res := False;
|
||||
end if;
|
||||
end loop;
|
||||
return Res;
|
||||
end "=";
|
||||
|
||||
function "<"(S1, S2 : in Cle_Contact) return Boolean is
|
||||
Res : Boolean := True;
|
||||
indice : Integer := S1'First;
|
||||
begin
|
||||
while Indice <= S1'Last and Res=True loop
|
||||
if S1(Indice) < S2(Indice) then
|
||||
Indice := Indice+1;
|
||||
else
|
||||
Res := False;
|
||||
end if;
|
||||
end loop;
|
||||
return Res;
|
||||
end "<";
|
||||
|
||||
procedure Liberer_Contact(C : in out Un_Contact) is
|
||||
begin
|
||||
Liberer_String(C.Nom);
|
||||
Liberer_String(C.Prenom);
|
||||
Liberer_String(C.Ville);
|
||||
Liberer_String(C.Specialite);
|
||||
--Liberer_String(C.Telephone);
|
||||
end Liberer_Contact;
|
||||
|
||||
|
||||
-- Egalite champ a champ sur les elements
|
||||
function Equal(C1, C2 : in Un_Contact) return Boolean is
|
||||
begin
|
||||
return C1.Nom.all = C2.Nom.all and C1.Prenom.all = C2.Prenom.all and C1.Ville.all = C2.Ville.all and C1.Specialite.all = C2.Specialite.all and C1.Telephone = C2.Telephone;
|
||||
end Equal;
|
||||
|
||||
-- Ordre alphabetique sur nom et prenom
|
||||
function Inf_OrdreAlpha(C1, C2 : in Un_Contact) return Boolean is
|
||||
begin
|
||||
return C1.Nom.all < C2.Nom.all or else (C1.Nom.all = C2.Nom.all and C1.Prenom.all < C2.Prenom.all);
|
||||
end Inf_OrdreAlpha;
|
||||
|
||||
|
||||
|
||||
end Contact_Cle;
|
|
@ -0,0 +1,46 @@
|
|||
-- Date : Mars 2015
|
||||
-- Auteur : MJ. Huguet
|
||||
--
|
||||
-- Objet : specification paquetage Contact (avec cle)
|
||||
--
|
||||
-----------------------------------------------------------------------------
|
||||
with Pointeurs_De_Strings;
|
||||
use Pointeurs_De_Strings;
|
||||
|
||||
package Contact_Cle is
|
||||
|
||||
type Un_Contact is private;
|
||||
subtype Cle_Contact is String(1..10);
|
||||
|
||||
function Creer_Contact(Nom, Prenom, Ville, Specialite, Telephone : in String) return Un_Contact;
|
||||
function Nom(C : in Un_Contact) return String;
|
||||
function Prenom(C : in Un_Contact) return String;
|
||||
function Ville(C : in Un_Contact) return String;
|
||||
function Specialite(C : in Un_Contact) return String;
|
||||
function Telephone(C : in Un_Contact) return Cle_Contact;
|
||||
|
||||
function Contact_To_String(C : in Un_Contact) return String;
|
||||
procedure Liberer_Contact(C : in out Un_Contact);
|
||||
|
||||
-- Cle : le champ Telephone sous forme d'entier
|
||||
-- fonction de comparaison sur la cle
|
||||
function Cle(C : in Un_Contact) return Cle_Contact;
|
||||
function"="(S1, S2 : Cle_Contact) return Boolean;
|
||||
function"<"(S1, S2 : Cle_Contact) return Boolean;
|
||||
|
||||
function Equal(C1, C2 : in Un_Contact) return Boolean;
|
||||
function Inf_OrdreAlpha(C1, C2 : in Un_Contact) return Boolean;
|
||||
|
||||
|
||||
|
||||
private
|
||||
|
||||
type Un_Contact is record
|
||||
Nom : P_String;
|
||||
Prenom : P_String;
|
||||
Ville : P_String;
|
||||
Specialite : P_String;
|
||||
Telephone : Cle_Contact;
|
||||
end record;
|
||||
|
||||
end Contact_Cle;
|
未顯示二進位檔案。
|
@ -0,0 +1,231 @@
|
|||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
with Contact_Cle; use Contact_Cle;
|
||||
with Arbre_Bin_Recherche_Cle_G;
|
||||
with Liste_Ordonnee_Cle_G;
|
||||
with Ada.IO_Exceptions;
|
||||
with Ada.Calendar; use Ada.Calendar;
|
||||
with Ada.Command_Line; use Ada.Command_Line;
|
||||
|
||||
|
||||
procedure Gerer_Annuaire_Inverse is
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-- Parametre du programme
|
||||
--
|
||||
-- Attention avec une valeur à TRUE le chargement de document volumineux
|
||||
-- est beaucoup plus long.
|
||||
|
||||
ANALYSE_AVEC_LISTE : Boolean := TRUE;
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
-- Instanciation des paquetages
|
||||
package Arbre_Contacts is new Arbre_Bin_Recherche_Cle_G(Un_Contact, Cle_contact, Cle, "<", "=", Liberer_Contact, Contact_To_string);
|
||||
use Arbre_Contacts;
|
||||
|
||||
package Liste_Contacts is new Liste_Ordonnee_Cle_G(Un_Contact, Cle_contact, Cle, "<", "=", Liberer_Contact, Contact_To_string);
|
||||
use Liste_Contacts;
|
||||
|
||||
procedure Att_Liste is begin
|
||||
New_Line;
|
||||
Put_Line("Attention l'utilisation de listes est ACTIVEE et non nécessaire !");
|
||||
Put_Line("L'option peut être désactivé à la compilation ou en passant le ");
|
||||
Put_Line("parametre -a à l'execution.");
|
||||
New_Line;
|
||||
Put_Line("L'argument -p peut être spécifié pour lancer des tests de performance.");
|
||||
New_Line;
|
||||
end Att_Liste;
|
||||
|
||||
Invalid_Argument : exception;
|
||||
|
||||
-- Variables pour la lecture du fichier annuaire
|
||||
Fichier : File_Type;
|
||||
Chaine, Ligne : String(1..80);
|
||||
Len, last : Integer := 0;
|
||||
AB : Arbre;
|
||||
C : Un_Contact;
|
||||
Tel : String(1..10);
|
||||
Auto : Boolean := False;
|
||||
Prenom, Nom, Ville, Specia, Telephone, Fin, I, compteur : Integer := 0;
|
||||
|
||||
-- Variables liées aux listes
|
||||
L : Une_Liste_Ordonnee;
|
||||
AnL : Boolean := ANALYSE_AVEC_LISTE;
|
||||
Performance : Boolean := False;
|
||||
|
||||
-- Varaibles temps
|
||||
T1, T2 , TA , TB: Time;
|
||||
|
||||
begin
|
||||
Put_Line("Programme d'annuaire inversé - Version ABR");
|
||||
|
||||
-- Analyse des arguments (s'il y en a)
|
||||
if Argument_Count = 1 and then Argument(1) = "-a" then AnL := FALSE; end if;
|
||||
if Argument_Count = 1 and then Argument(1) = "-p" then Performance := TRUE; end if;
|
||||
|
||||
if Argument_Count = 2 and then ((Argument(1) = "-a" and Argument(2) = "-p") or ((Argument(1) = "-p" and Argument(2) = "-a"))) then AnL := FALSE; Performance := TRUE; end if;
|
||||
|
||||
if Performance and not AnL then raise Invalid_Argument; end if;
|
||||
|
||||
|
||||
|
||||
if AnL then Att_Liste; end if;
|
||||
|
||||
-- Entourloupe pour avoir un nom de fichier contraint, saisi par l'utilisateur et de bonne taille
|
||||
Put_Line("Nom de l'annuaire: ");
|
||||
Get_Line(Chaine, Len);
|
||||
|
||||
-- (1) Option de test simple: si on laisse le champ vide, l'annuaire "T_10.txt" sera chargé
|
||||
if Len = 0 and not AnL then Len := 12; Auto := True; end if;
|
||||
|
||||
-- On récupère le contenu du fichier choisi
|
||||
declare
|
||||
Nom_Fichier : String(Chaine'First..Len) := Chaine(Chaine'First..Len);
|
||||
Cle_Cherche : Cle_Contact;
|
||||
begin
|
||||
-- (1)
|
||||
if Auto then Nom_Fichier := "A_150000.txt"; end if;
|
||||
|
||||
-- On ouvre le fichier dans "Fichier"
|
||||
open(Fichier, in_File, "./jeux_de_donnees/" & Nom_Fichier);
|
||||
Put_Line("Début du chargemnt du fichier...");
|
||||
Compteur := 0;
|
||||
|
||||
-- Tant qu'on n'a pas atteint la fin du fichier
|
||||
while not End_Of_File(Fichier) loop
|
||||
Get_Line (Fichier, Ligne , Len ) ;
|
||||
|
||||
-- Variables pour marquer les positions des différents éléments
|
||||
Prenom := 1;
|
||||
Nom := 0;
|
||||
Ville := 0;
|
||||
Specia := 0;
|
||||
Telephone := 0;
|
||||
Fin := 0;
|
||||
I := 1;
|
||||
|
||||
-- On transforme une chaine de caractère en contact
|
||||
while Telephone = 0 loop
|
||||
if Ligne(I) = ' ' then
|
||||
if Nom = 0 then Nom := I;
|
||||
elsif Ville = 0 then Ville := I;
|
||||
elsif Specia = 0 then Specia := I;
|
||||
elsif Telephone = 0 then Telephone := I; Fin := Telephone + 11;
|
||||
end if;
|
||||
end if;
|
||||
I := I + 1;
|
||||
end loop;
|
||||
C := Creer_Contact(Ligne(Prenom..Nom-1), Ligne(Nom+1..Ville-1), Ligne(Ville+1..Specia-1), Ligne(Specia+1..Telephone-1), Ligne(Telephone+1..Fin-1));
|
||||
|
||||
-- On insère le contact créé dans un arbre et / ou une liste
|
||||
Inserer(C, AB);
|
||||
if AnL then Inserer(C, L); end if; -- Ssi l'option est activée
|
||||
|
||||
-- Compte du nombre de contacts chargés pour un meilleur suivi
|
||||
Compteur := Compteur + 1;
|
||||
if (Compteur mod 1000) = 0 then
|
||||
Put_Line(Integer'Image(Compteur) & " contacts chargés");
|
||||
if AnL and then Compteur mod 10000 = 0 then Att_Liste; end if;
|
||||
end if;
|
||||
|
||||
end loop;
|
||||
Put_Line("Fin du chargement du ficier...");
|
||||
Close(Fichier);
|
||||
Put_Line("Annuaire en mémoire.");
|
||||
New_Line;
|
||||
|
||||
|
||||
-- La liste contient l'annuaire donné
|
||||
--Put_Line("Liste avec les contacts : ");
|
||||
--Put_Line(Liste_To_String(L));
|
||||
--New_Line;
|
||||
|
||||
if not Performance then
|
||||
loop
|
||||
-- L'arbre AB contient l'annuaire saisi
|
||||
-- on fait donc la recherche dans cet arbre
|
||||
|
||||
Put_Line("Veillez saisir un numéro à rechercher: ");
|
||||
Get_Line(Cle_Cherche, Len);
|
||||
|
||||
-- Recherche dans l'arbre
|
||||
Put_Line("Recherche de " & Cle_Cherche & " dans l'arbre");
|
||||
T1 := Clock;
|
||||
C := Rechercher_Par_Cle(Cle_cherche, AB);
|
||||
T2 := Clock;
|
||||
Put_Line("Entrée trouvée : " & Contact_To_String(C));
|
||||
Put_Line("La recherche a durée : " & Duration'Image(T2 - T1));
|
||||
New_Line;
|
||||
|
||||
-- Recherche dans la liste
|
||||
if AnL then
|
||||
Put_Line("Recherche dans la liste : ");
|
||||
T1 := Clock;
|
||||
C := Rechercher_Par_Cle(Cle_cherche, L);
|
||||
T2 := Clock;
|
||||
Put_Line("Entrée trouvée : " & Contact_To_String(C));
|
||||
Put_Line("La recherche a durée : " & Duration'Image(T2 - T1));
|
||||
end if;
|
||||
|
||||
New_Line;
|
||||
end loop;
|
||||
end if;
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------
|
||||
|
||||
-- Tests de performance
|
||||
New_Line;
|
||||
Put_Line("Test de performance des différentes structures : ");
|
||||
|
||||
if not AnL then raise Invalid_Argument; end if;
|
||||
|
||||
Put_Line("On recherche tout les éléments présent dans chaque structure.");
|
||||
open(Fichier, in_File, "./jeux_de_donnees/performance/" & Nom_Fichier & ".perf");
|
||||
|
||||
Put_Line("Recherche dans l'arbre : ");
|
||||
TA := Clock;
|
||||
while not End_Of_File(Fichier) loop
|
||||
Tel := Get_Line(Fichier)(1..10);
|
||||
Put("Arbre : Recherche de " & Tel & "... ");
|
||||
C := Rechercher_Par_Cle(Tel, AB);
|
||||
Put_Line("Trouvé !");
|
||||
end loop;
|
||||
TB := Clock;
|
||||
|
||||
Put_Line("La recherche de l'ensemble des éléments dans un arbre a durée : " & Duration'Image(TB - TA));
|
||||
New_Line;
|
||||
|
||||
Reset(Fichier);
|
||||
|
||||
Put_Line("Recherche dans la liste : ");
|
||||
T1 := Clock;
|
||||
while not End_Of_File(Fichier) loop
|
||||
Tel := Get_Line(Fichier)(1..10);
|
||||
Put("Liste : Recherche de " & Tel & "... ");
|
||||
C := Rechercher_Par_Cle(Tel, L);
|
||||
Put_Line("Trouvé !");
|
||||
end loop;
|
||||
T2 := Clock;
|
||||
|
||||
Put_Line("La recherche de l'ensemble des éléments dans une liste a durée : " & Duration'Image(T2 - T1));
|
||||
New_Line;
|
||||
|
||||
Put_Line("Résultats :");
|
||||
Put_Line("Arbre : " & Duration'Image(TB - TA));
|
||||
Put_Line("Liste : " & Duration'Image(T2 - T1));
|
||||
|
||||
New_Line;
|
||||
Put_Line("...fini.");
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------
|
||||
|
||||
exception
|
||||
when Invalid_Argument => Put_Line("L'argument -a a été spécifié, les tests de performnces ne peuvent pas avoir lieu."); raise PROGRAM_ERROR;
|
||||
when Arbre_Contacts.Element_Non_Present => Put_Line("Equivalence numéro introuvable.");
|
||||
when ADA.IO_EXCEPTIONS.NAME_ERROR => Put_Line("Fichier invalide.");
|
||||
end;
|
||||
end Gerer_Annuaire_Inverse;
|
檔案差異因為檔案過大而被隱藏
載入差異
|
@ -0,0 +1,100 @@
|
|||
Christina Salvietti Dunkerque Stomatologue 0614557340
|
||||
Thomas Dalton Orleans Rhumatologue 0717045284
|
||||
Michael Hemp Pantin Psychiatre 0789751830
|
||||
Christopher Chalmers Suresnes Veterinaire 0765856048
|
||||
Kathrine Hall Tours Radiologue 0723029341
|
||||
Robin Cook Angers Dermatologue 0771690567
|
||||
Alexander Seaberry Versailles Veterinaire 0688468848
|
||||
Lydia Gunter Montrouge Radiologue 0791786318
|
||||
Ronald Berry Pantin Urologue 0766359222
|
||||
Ralph Getz Perpignan Pediatre 0736397458
|
||||
Sarah Venhorst Arles Cardiologue 0718276125
|
||||
Dorothy Schrenk Dijon Psychiatre 0730529239
|
||||
Valerie Hill Courbevoie Gynecologue 0740938552
|
||||
Bethany Hemmingsen Belfort Pharmacien 0661965668
|
||||
Alex Sircy Carcassonne Dentiste 0767042063
|
||||
Dawn Orduna Limoges Pharmacien 0729276847
|
||||
John Roberts Valence Ophtalmologie 0606017296
|
||||
Kirk Mentzer Beziers Stomatologue 0754938171
|
||||
Rod Brandes Beauvais Ophtalmologie 0677493599
|
||||
Ann Collins Drancy Rhumatologue 0728051106
|
||||
Lyle Lynch Bordeaux Pneumologue 0611081673
|
||||
Daniel Gaytan Nimes Dentiste 0734320107
|
||||
Maria Clayton Cayenne Stomatologue 0707951067
|
||||
Michelle Szaflarski Bourges Rhumatologue 0671359079
|
||||
Connie Myles Rouen Psychiatre 0670774856
|
||||
Michelle Koller Angers Orthodontiste 0789861804
|
||||
Burton Gould Meaux Kinesitherapeute 0759713789
|
||||
William Downs Metz Urologue 0624420780
|
||||
Warren Thacker Cannes Pharmacien 0787114057
|
||||
Gabrielle Atwood Vincennes Kinesitherapeute 0717448326
|
||||
Nancy Schlemmer Cergy Stomatologue 0680012397
|
||||
Joshua Sheahan Belfort ORL 0751676741
|
||||
Janet Matusz Limoges Infirmier 0679596606
|
||||
June Phillips Frejus Cardiologue 0794575429
|
||||
Bonnie Henry Bourges Pharmacien 0733255479
|
||||
Brad Tinajero Niort ORL 0787004064
|
||||
Diane Brody Paris Stomatologue 0619689557
|
||||
Andrew Brizuela Perpignan Veterinaire 0725147359
|
||||
Tiffany Johnson Montpellier Cardiologue 0662233729
|
||||
Jean Ball Beauvais Psychologue 0619930405
|
||||
Edwin Womack Pessac Cardiologue 0610446516
|
||||
Walter Lee Mulhouse Urologue 0736737546
|
||||
Lionel Garrison Sarcelles Urologue 0626162381
|
||||
Ted Ross Limoges Dermatologue 0736812823
|
||||
Joseph Burgos Merignac Dermatologue 0686454461
|
||||
Helen Rudd Suresnes Rhumatologue 0720159880
|
||||
John Edwards Colombes Stomatologue 0786816630
|
||||
Patricia Mckenzie Bayonne Radiologue 0799285175
|
||||
Barry Washington Carcassonne Gynecologue 0629044930
|
||||
Brent Rumph Dunkerque Kinesitherapeute 0601686369
|
||||
Howard Hopper Calais Gynecologue 0736698485
|
||||
Willie Morber Pessac Pharmacien 0684229819
|
||||
Debra Ferro Argenteuil Dermatologue 0715229166
|
||||
Jewell Browne Clamart Infirmier 0613448062
|
||||
Marjorie Phillips Beziers Dentiste 0626771559
|
||||
Bobbie Dickson Roubaix Veterinaire 0752944999
|
||||
Dorothy Taylor Drancy Pneumologue 0727657312
|
||||
Shelley Toure Albi Ophtalmologie 0728248225
|
||||
Jacqueline Lowe Lorient Psychologue 0766130683
|
||||
Thelma Joyce Sartrouville Psychologue 0782053265
|
||||
Taneka Bonnell Nancy Gynecologue 0708715730
|
||||
Johnny Verduzco Martigues Dermatologue 0640313570
|
||||
Lydia Stahnke Perpignan Gynecologue 0654914801
|
||||
Noel Seng Colmar Pharmacien 0640985650
|
||||
Patricia Mancia Nantes Pharmacien 0661452251
|
||||
Andrew Edison Cannes Infirmier 0682646757
|
||||
George Chan Clichy Pediatre 0704365146
|
||||
Laura Krajewski Tours Pneumologue 0728727260
|
||||
Matthew Ringwood Cergy Oncologue 0769681461
|
||||
Kenneth Cox Sevran Pneumologue 0651190403
|
||||
Odell Anderson Dijon Dentiste 0644008941
|
||||
Cynthia Stelling Antony Pneumologue 0709334530
|
||||
Fred Collins Lyon Psychiatre 0768046535
|
||||
Robert Rose Paris Dermatologue 0696752326
|
||||
Ronald Carpenter Tourcoing ORL 0798115523
|
||||
Carolyn Jordan Montrouge Ophtalmologie 0670251464
|
||||
Scott Harris Montpellier Orthodontiste 0671519724
|
||||
John Turner Brest Urologue 0666825542
|
||||
Arturo Strobel Lorient Veterinaire 0718350189
|
||||
Mary Byrd Calais ORL 0770391790
|
||||
Maria Castillo Villejuif Psychiatre 0640320392
|
||||
Helen Smith Venissieux Cardiologue 0710300526
|
||||
Elizabeth Runyon Lyon Cardiologue 0754831274
|
||||
Irma Lebeau Chambery Veterinaire 0622965436
|
||||
Raul Petrick Orleans Gynecologue 0782714832
|
||||
Genevieve White Sartrouville Kinesitherapeute 0701551618
|
||||
Charlotte Allred Lyon Psychologue 0779128443
|
||||
Ashley Golish Clichy Dermatologue 0733829538
|
||||
Christopher Marshall Perpignan Pneumologue 0608430736
|
||||
Patricia Martinez Creteil Urologue 0708675019
|
||||
Shawn Depue Quimper Urologue 0771007917
|
||||
James Whitaker Antibes Rhumatologue 0708105493
|
||||
Venus Heath Merignac Ophtalmologie 0764982294
|
||||
Henry Taylor Quimper Pediatre 0627414030
|
||||
Gerald Ward Antony Infirmier 0760432900
|
||||
Pearlie Wallace Lorient Oncologue 0678446542
|
||||
Darrell Dingman Aubervilliers Pneumologue 0742554197
|
||||
John Wingard Vincennes Rhumatologue 0610835804
|
||||
Regina Mitchell Cergy Kinesitherapeute 0799055623
|
||||
Amanda Johnson Paris Pharmacien 0783971691
|
檔案差異因為檔案過大而被隱藏
載入差異
檔案差異因為檔案過大而被隱藏
載入差異
檔案差異因為檔案過大而被隱藏
載入差異
|
@ -0,0 +1,100 @@
|
|||
Jason Ramirez Cayenne Dermatologue 0601469441
|
||||
Paul Adkins Clichy Pharmacien 0602268057
|
||||
Larry White Villeurbanne Pediatre 0604356724
|
||||
Marcella Boteilho Montpellier Pharmacien 0605224418
|
||||
Connie Cooksey Tours ORL 0605740643
|
||||
Cynthia Stammel Vannes Stomatologue 0606069401
|
||||
Ricky Gaskins Bourges Gynecologue 0607633062
|
||||
John Casey Quimper Stomatologue 0612865145
|
||||
Philip Erwin Evry Gynecologue 0614081922
|
||||
Maria Jacobs Pau Dermatologue 0615785657
|
||||
Sandra Bartley Grasse Dentiste 0621732897
|
||||
Edgar Bailie Tours Dermatologue 0624519053
|
||||
Jake Larkin Colombes Infirmier 0625330358
|
||||
Eric Harding Antibes Psychiatre 0628149430
|
||||
Patricia Forrest Orleans Stomatologue 0630153546
|
||||
Matthew Harriman Frejus Rhumatologue 0630349477
|
||||
Kelly Randle Metz Pneumologue 0631183761
|
||||
Robert Quincy Marseille Dermatologue 0631258707
|
||||
Craig Schwartz Perpignan Rhumatologue 0639863302
|
||||
Melissa Lawhorn Merignac Pneumologue 0641574403
|
||||
Kim Hildreth Argenteuil Pediatre 0641908377
|
||||
Peter Long Nancy Orthodontiste 0642485116
|
||||
Victoria Bookman Lille Stomatologue 0644959823
|
||||
Jeffery Clark Montrouge Ophtalmologie 0648294804
|
||||
Leona Delisi Colombes Psychologue 0649441977
|
||||
Erika Jessup Argenteuil Infirmier 0650142977
|
||||
Chi Scoggins Troyes Pediatre 0654342363
|
||||
William Turner Sartrouville Pediatre 0655203465
|
||||
Kathy Ramirez Cergy ORL 0656262558
|
||||
Kathleen Woodruff Arles Veterinaire 0657249252
|
||||
Harold Redenbaugh Bobigny Kinesitherapeute 0660776057
|
||||
Eduardo Harper Drancy Pediatre 0661387296
|
||||
Doris Childs Evry Gynecologue 0662708341
|
||||
Leslie Sundt Grenoble Rhumatologue 0665241194
|
||||
Abram Kelly Sarcelles Ophtalmologie 0667282459
|
||||
Roy Scott Calais Cardiologue 0678927491
|
||||
Justin Garcia Rennes Dentiste 0681054726
|
||||
Olga Corvin Clichy Gynecologue 0681846139
|
||||
Irene Calhoun Villeurbanne Radiologue 0684144734
|
||||
Jody Johnson Lorient Stomatologue 0684502123
|
||||
Robert Witham Sarcelles Kinesitherapeute 0686187837
|
||||
Holly Pruitt Nice Kinesitherapeute 0690423255
|
||||
Carlos Rison Montauban Dermatologue 0696704526
|
||||
Keith Mota Limoges Veterinaire 0698170210
|
||||
Rhonda Irby Carcassonne Kinesitherapeute 0701503627
|
||||
Debra Simmons Troyes Cardiologue 0703288515
|
||||
Peter Cox Bobigny Cardiologue 0704332413
|
||||
Tosha Heinbach Dijon Gynecologue 0705162957
|
||||
Kenneth Lawrence Nancy Ophtalmologie 0705406371
|
||||
Daniel Slevin Chambery Rhumatologue 0707151590
|
||||
Franklin Baker Paris Rhumatologue 0709305684
|
||||
Sonia Satterwhite Evry Radiologue 0709550131
|
||||
Geneva Stenn Bordeaux Gynecologue 0710075283
|
||||
Alice Griffy Nice Orthodontiste 0710934802
|
||||
Michael Irwin Bayonne Pharmacien 0712350585
|
||||
David Peterson Nice ORL 0715265740
|
||||
Monique Johnson Clichy Radiologue 0719342067
|
||||
Jessie Beaman Pantin Dermatologue 0719417697
|
||||
Charles Sanyaro Villeurbanne Orthodontiste 0720356493
|
||||
James Lindsey Chambery Rhumatologue 0721248905
|
||||
Virginia Allen Rouen Oncologue 0722925021
|
||||
Samuel Mackillop Annecy Dentiste 0724148510
|
||||
Timothy Thomas Arles Orthodontiste 0724414755
|
||||
Joyce Kindrick Frejus Oncologue 0725413006
|
||||
Freddie Bintner Lorient ORL 0728686818
|
||||
Bryce Herring Albi Rhumatologue 0732739821
|
||||
Josephine Whitehurst Pantin Orthodontiste 0734427363
|
||||
Jessica Francois Amiens Pediatre 0736783189
|
||||
Patricia Lewis Poitiers ORL 0740644722
|
||||
Michelle Rosario Marseille Stomatologue 0741537047
|
||||
Buddy Anderson Grenoble Orthodontiste 0741605824
|
||||
Ricky Ehrhardt Annecy Gynecologue 0742366068
|
||||
Derek Ezell Albi Rhumatologue 0743172458
|
||||
Lorita Standridge Suresnes Urologue 0743287915
|
||||
Alexandra Tullar Belfort ORL 0744054303
|
||||
Donna Glover Bayonne Pneumologue 0746300880
|
||||
Anna Toon Arles Ophtalmologie 0751712965
|
||||
Chang Ray Colombes Gynecologue 0755354553
|
||||
Mary Flores Laval Psychologue 0759792709
|
||||
Alejandrina Gibson Toulon Dentiste 0761143543
|
||||
Daniel Gross Marseille Gynecologue 0761364927
|
||||
Frank Lish Cergy Psychiatre 0762411393
|
||||
Dean Deppe Pessac Psychiatre 0765100432
|
||||
James Shy Brest Psychologue 0766767527
|
||||
Julie Anthony Carcassonne Dermatologue 0767409084
|
||||
Matt Patterson Avignon Rhumatologue 0771974938
|
||||
Edna Malcolm Villejuif Radiologue 0775564082
|
||||
Barbara Booth Roubaix Urologue 0775866258
|
||||
Joanna Hine Quimper Cardiologue 0777867516
|
||||
Roy Higgins Versailles Radiologue 0777908263
|
||||
Jose Chandler Vincennes Kinesitherapeute 0778332698
|
||||
Christine Collins Niort Infirmier 0778787127
|
||||
Daniel Adkisson Clamart Pneumologue 0779033634
|
||||
Daryl Swain Paris ORL 0779406882
|
||||
Belle Scott Laval Dentiste 0782884192
|
||||
Daniel Carpenter Tours Pneumologue 0785010855
|
||||
Deborah Ewing Pau Pediatre 0786096527
|
||||
Michael Long Ajaccio Pediatre 0789814751
|
||||
Charlie Ortiz Bondy Dentiste 0799036472
|
||||
Elizabeth Strunk Rennes Psychologue 0799416523
|
檔案差異因為檔案過大而被隱藏
載入差異
檔案差異因為檔案過大而被隱藏
載入差異
檔案差異因為檔案過大而被隱藏
載入差異
|
@ -0,0 +1,10 @@
|
|||
Charles Chang Beziers ORL 0703888032
|
||||
Martha Bibbs Beauvais Psychiatre 0616751216
|
||||
Jerry Joosten Albi Pharmacien 0724258260
|
||||
Elijah Taylor Caen Orthodontiste 0770222606
|
||||
Gary Maupin Bayonne Rhumatologue 0705071875
|
||||
William Snider Tours Radiologue 0621112196
|
||||
Josefa Eckel Villeurbanne Kinesitherapeute 0784142335
|
||||
John Brunton Lorient Oncologue 0617519421
|
||||
Ronald Crank Montreuil Dentiste 0668920050
|
||||
Joanne Ramos Sevran Veterinaire 0657148529
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
#Permet de créer les fichiers de performance à partir des annuaires
|
||||
for i in `ls`
|
||||
do
|
||||
if test -f $i
|
||||
then
|
||||
cat $i | awk '{print $5}' > performance/$i.perf
|
||||
fi
|
||||
echo "$i done !"
|
||||
done
|
||||
echo "done"
|
|
@ -0,0 +1,100 @@
|
|||
0614557340
|
||||
0717045284
|
||||
0789751830
|
||||
0765856048
|
||||
0723029341
|
||||
0771690567
|
||||
0688468848
|
||||
0791786318
|
||||
0766359222
|
||||
0736397458
|
||||
0718276125
|
||||
0730529239
|
||||
0740938552
|
||||
0661965668
|
||||
0767042063
|
||||
0729276847
|
||||
0606017296
|
||||
0754938171
|
||||
0677493599
|
||||
0728051106
|
||||
0611081673
|
||||
0734320107
|
||||
0707951067
|
||||
0671359079
|
||||
0670774856
|
||||
0789861804
|
||||
0759713789
|
||||
0624420780
|
||||
0787114057
|
||||
0717448326
|
||||
0680012397
|
||||
0751676741
|
||||
0679596606
|
||||
0794575429
|
||||
0733255479
|
||||
0787004064
|
||||
0619689557
|
||||
0725147359
|
||||
0662233729
|
||||
0619930405
|
||||
0610446516
|
||||
0736737546
|
||||
0626162381
|
||||
0736812823
|
||||
0686454461
|
||||
0720159880
|
||||
0786816630
|
||||
0799285175
|
||||
0629044930
|
||||
0601686369
|
||||
0736698485
|
||||
0684229819
|
||||
0715229166
|
||||
0613448062
|
||||
0626771559
|
||||
0752944999
|
||||
0727657312
|
||||
0728248225
|
||||
0766130683
|
||||
0782053265
|
||||
0708715730
|
||||
0640313570
|
||||
0654914801
|
||||
0640985650
|
||||
0661452251
|
||||
0682646757
|
||||
0704365146
|
||||
0728727260
|
||||
0769681461
|
||||
0651190403
|
||||
0644008941
|
||||
0709334530
|
||||
0768046535
|
||||
0696752326
|
||||
0798115523
|
||||
0670251464
|
||||
0671519724
|
||||
0666825542
|
||||
0718350189
|
||||
0770391790
|
||||
0640320392
|
||||
0710300526
|
||||
0754831274
|
||||
0622965436
|
||||
0782714832
|
||||
0701551618
|
||||
0779128443
|
||||
0733829538
|
||||
0608430736
|
||||
0708675019
|
||||
0771007917
|
||||
0708105493
|
||||
0764982294
|
||||
0627414030
|
||||
0760432900
|
||||
0678446542
|
||||
0742554197
|
||||
0610835804
|
||||
0799055623
|
||||
0783971691
|
檔案差異因為檔案過大而被隱藏
載入差異
檔案差異因為檔案過大而被隱藏
載入差異
檔案差異因為檔案過大而被隱藏
載入差異
|
@ -0,0 +1,100 @@
|
|||
0601469441
|
||||
0602268057
|
||||
0604356724
|
||||
0605224418
|
||||
0605740643
|
||||
0606069401
|
||||
0607633062
|
||||
0612865145
|
||||
0614081922
|
||||
0615785657
|
||||
0621732897
|
||||
0624519053
|
||||
0625330358
|
||||
0628149430
|
||||
0630153546
|
||||
0630349477
|
||||
0631183761
|
||||
0631258707
|
||||
0639863302
|
||||
0641574403
|
||||
0641908377
|
||||
0642485116
|
||||
0644959823
|
||||
0648294804
|
||||
0649441977
|
||||
0650142977
|
||||
0654342363
|
||||
0655203465
|
||||
0656262558
|
||||
0657249252
|
||||
0660776057
|
||||
0661387296
|
||||
0662708341
|
||||
0665241194
|
||||
0667282459
|
||||
0678927491
|
||||
0681054726
|
||||
0681846139
|
||||
0684144734
|
||||
0684502123
|
||||
0686187837
|
||||
0690423255
|
||||
0696704526
|
||||
0698170210
|
||||
0701503627
|
||||
0703288515
|
||||
0704332413
|
||||
0705162957
|
||||
0705406371
|
||||
0707151590
|
||||
0709305684
|
||||
0709550131
|
||||
0710075283
|
||||
0710934802
|
||||
0712350585
|
||||
0715265740
|
||||
0719342067
|
||||
0719417697
|
||||
0720356493
|
||||
0721248905
|
||||
0722925021
|
||||
0724148510
|
||||
0724414755
|
||||
0725413006
|
||||
0728686818
|
||||
0732739821
|
||||
0734427363
|
||||
0736783189
|
||||
0740644722
|
||||
0741537047
|
||||
0741605824
|
||||
0742366068
|
||||
0743172458
|
||||
0743287915
|
||||
0744054303
|
||||
0746300880
|
||||
0751712965
|
||||
0755354553
|
||||
0759792709
|
||||
0761143543
|
||||
0761364927
|
||||
0762411393
|
||||
0765100432
|
||||
0766767527
|
||||
0767409084
|
||||
0771974938
|
||||
0775564082
|
||||
0775866258
|
||||
0777867516
|
||||
0777908263
|
||||
0778332698
|
||||
0778787127
|
||||
0779033634
|
||||
0779406882
|
||||
0782884192
|
||||
0785010855
|
||||
0786096527
|
||||
0789814751
|
||||
0799036472
|
||||
0799416523
|
檔案差異因為檔案過大而被隱藏
載入差異
檔案差異因為檔案過大而被隱藏
載入差異
檔案差異因為檔案過大而被隱藏
載入差異
|
@ -0,0 +1,10 @@
|
|||
0703888032
|
||||
0616751216
|
||||
0724258260
|
||||
0770222606
|
||||
0705071875
|
||||
0621112196
|
||||
0784142335
|
||||
0617519421
|
||||
0668920050
|
||||
0657148529
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'{print
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
-- Date : Mars 2015
|
||||
-- Auteur : MJ. Huguet
|
||||
--
|
||||
-- Objet : corps liste ordonnee generique
|
||||
--
|
||||
-- Remarque :
|
||||
-- les elements disposent d'une cle permettant de les identifier
|
||||
-----------------------------------------------------------------------------
|
||||
with Ada.Unchecked_Deallocation;
|
||||
|
||||
package body Liste_Ordonnee_Cle_G is
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Definir l'egalite sur des elements comme l'egalite sur la cle
|
||||
-- c'est pour blinder la definition d'une cle !!!
|
||||
function "="(E1, E2 : Element) return Boolean is
|
||||
begin
|
||||
return Cle_De(E1)=Cle_De(E2);
|
||||
end "=";
|
||||
function "<"(E1, E2 : Element) return Boolean is
|
||||
begin
|
||||
return Cle_De(E1)<Cle_De(E2);
|
||||
end "<";
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
function Est_Vide(L : in Une_Liste_Ordonnee) return Boolean is
|
||||
begin
|
||||
return L.Debut = null;
|
||||
end Est_Vide;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
function Cardinal(L : in Une_Liste_Ordonnee) return Integer is
|
||||
begin
|
||||
return L.Taille;
|
||||
end Cardinal;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Appartient classique sur une liste simplement chainee (type Lien) ordonnee
|
||||
-- base sur un element
|
||||
function Appartient_Lien(E : in Element; LL : in Lien) return Boolean is
|
||||
Resultat :boolean;
|
||||
begin
|
||||
if LL = null or else E < LL.all.Info then
|
||||
Resultat := False; -- element non trouve
|
||||
elsif E = LL.all.Info then
|
||||
Resultat := True; -- element trouve en 1ere place
|
||||
else
|
||||
Resultat := Appartient_Lien(E, LL.all.Suiv); -- on cherche plus loin
|
||||
end if;
|
||||
return Resultat;
|
||||
end Appartient_Lien;
|
||||
|
||||
function Appartient(E : in Element; L : in Une_Liste_Ordonnee) return Boolean is
|
||||
begin
|
||||
return Appartient_Lien(E, L.Debut);
|
||||
end Appartient;
|
||||
|
||||
-- base sur une cle
|
||||
function Appartient_Lien(C : in Key; LL : in Lien) return Boolean is
|
||||
Resultat :boolean;
|
||||
begin
|
||||
if LL = null or else C < Cle_De(LL.all.Info) then
|
||||
Resultat := False; -- element non trouve
|
||||
elsif C = Cle_De(LL.all.Info) then
|
||||
Resultat := True; -- element trouve en 1ere place
|
||||
else
|
||||
Resultat := Appartient_Lien(C, LL.all.Suiv); -- on cherche plus loin
|
||||
end if;
|
||||
return Resultat;
|
||||
end Appartient_Lien;
|
||||
|
||||
function Appartient(C : in Key; L : in Une_Liste_Ordonnee) return Boolean is
|
||||
begin
|
||||
return Appartient_Lien(C, L.Debut);
|
||||
end Appartient;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-- Conversion en chaine de caracteres
|
||||
--
|
||||
-- sur le type Lien
|
||||
|
||||
function Lien_To_String(LL : in Lien) return String is
|
||||
begin
|
||||
if LL = null then return "";
|
||||
else return Element_To_String(LL.all.info) & Lien_To_String(LL.all.suiv);
|
||||
end if;
|
||||
end Lien_To_String;
|
||||
|
||||
-- sur le type Une_Liste_Ordonnee_Entiers
|
||||
function Liste_To_String(L: in Une_Liste_Ordonnee) return String is
|
||||
begin
|
||||
return Integer'Image(L.Taille) & " elements : (" & Lien_To_String(L.Debut) & " )";
|
||||
end Liste_To_String;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-- Insertion ORDONNEE et SANS DOUBLON
|
||||
-- A CORRIGER PAR LES ETUDIANTS (FAIT ICI)
|
||||
procedure Inserer_Lien(E: in Element; LL: in out Lien) is
|
||||
begin
|
||||
if LL=null then
|
||||
LL := new Cellule'(E, LL);
|
||||
elsif E < LL.all.Info then
|
||||
-- LL := new Cellule'(E, LL.all.Suiv);
|
||||
LL:= new Cellule'(E, LL); -- la correction est ici !
|
||||
elsif E=LL.all.Info then
|
||||
raise Element_Deja_Present;
|
||||
else
|
||||
Inserer_Lien(E, LL.all.Suiv);
|
||||
end if;
|
||||
end Inserer_Lien;
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
procedure Inserer(E: in Element; L: in out Une_Liste_Ordonnee) is
|
||||
begin
|
||||
Inserer_Lien(E, L.Debut);
|
||||
L.Taille := L.Taille + 1;
|
||||
end Inserer;
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
|
||||
-- Instanciation de Ada.Unchecked_Deallocation pour desallouer
|
||||
-- la memoire en cas de suppression des elements d'une liste
|
||||
-------------------------------------------------------------------------
|
||||
procedure Free is new Ada.Unchecked_Deallocation(Cellule, Lien);
|
||||
-------------------------------------------------------------------------
|
||||
procedure Supprimer_Lien(E : in Element; LL: in out Lien) is
|
||||
Recup : Lien;
|
||||
begin
|
||||
if LL = null or else E < LL.All.Info then
|
||||
raise Element_Non_Present;
|
||||
elsif E = LL.All.Info then
|
||||
Recup := LL; -- on repere la cellule a recycler
|
||||
LL := LL.All.Suiv; -- on modifie le debut de la liste
|
||||
Free(Recup); -- on recupere la memoire
|
||||
else
|
||||
Supprimer_Lien(E, LL.all.suiv);
|
||||
end if;
|
||||
end Supprimer_Lien;
|
||||
-------------------------------------------------------------------------
|
||||
procedure Supprimer(E: in Element; L: in out Une_Liste_Ordonnee) is
|
||||
begin
|
||||
Supprimer_Lien(E, L.debut);
|
||||
L.Taille := L.Taille - 1;
|
||||
end Supprimer;
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
function Rechercher_Lien(C : in Key; LL : in Lien) return Element is
|
||||
begin
|
||||
if LL = null or else C < Cle_De(LL.all.Info) then
|
||||
raise Element_Non_Present;
|
||||
else
|
||||
if C = Cle_De(LL.All.Info) then
|
||||
return LL.all.Info;
|
||||
else
|
||||
return Rechercher_Lien(C, LL.All.Suiv);
|
||||
end if;
|
||||
end if;
|
||||
end Rechercher_Lien;
|
||||
|
||||
function Rechercher_Par_Cle(C : in Key; L : Une_Liste_Ordonnee) return Element is
|
||||
begin
|
||||
return Rechercher_Lien(C, L.Debut);
|
||||
end Rechercher_Par_Cle;
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
procedure Filtrage(L : in Une_Liste_Ordonnee; SL : out Une_Liste_Ordonnee) is
|
||||
Aux : Lien := L.Debut;
|
||||
begin
|
||||
while Aux /= null loop
|
||||
if Selection(Aux.all.Info) then
|
||||
Inserer(Aux.all.Info, SL);
|
||||
end if;
|
||||
Aux := Aux.all.Suiv;
|
||||
end loop;
|
||||
end Filtrage;
|
||||
|
||||
end Liste_Ordonnee_Cle_G;
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
-- Date : Mars 2015
|
||||
-- Auteur : MJ. Huguet
|
||||
--
|
||||
-- Objet : specification liste ordonnee generique
|
||||
--
|
||||
-- Remarque :
|
||||
-- les elements disposent d'une cle permettant de les identifier
|
||||
-----------------------------------------------------------------------------
|
||||
generic
|
||||
type Element is private;
|
||||
type Key is private;
|
||||
with function Cle_De(E : in Element) return Key;
|
||||
with function "<"(C1, C2 : in Key) return Boolean;
|
||||
with function "="(C1, C2 : in Key) return Boolean;
|
||||
with procedure Free_Element(E : in out Element);
|
||||
with function Element_To_String(E : in Element) return String;
|
||||
|
||||
package Liste_Ordonnee_Cle_G is
|
||||
type Une_Liste_Ordonnee is limited private;
|
||||
|
||||
Element_Non_Present, Element_Deja_Present : exception;
|
||||
|
||||
function Est_Vide(L : in Une_Liste_Ordonnee) return Boolean;
|
||||
function Cardinal(L : in Une_Liste_Ordonnee) return Integer;
|
||||
function Appartient(E : in Element; L : in Une_Liste_Ordonnee) return Boolean;
|
||||
function Appartient(C : in Key; L : in Une_Liste_Ordonnee) return Boolean;
|
||||
procedure Inserer(E: in Element; L: in out Une_Liste_Ordonnee);
|
||||
procedure Supprimer(E: in Element; L: in out Une_Liste_Ordonnee);
|
||||
function Liste_To_String(L: in Une_Liste_Ordonnee) return String;
|
||||
|
||||
function Rechercher_Par_Cle(C : in Key; L : Une_Liste_Ordonnee) return Element;
|
||||
|
||||
generic
|
||||
with function Selection(E : in Element) return Boolean;
|
||||
procedure Filtrage(L : in Une_Liste_Ordonnee; SL : out Une_Liste_Ordonnee);
|
||||
|
||||
private
|
||||
-- types classiques permettant de realiser des listes simplement chainees
|
||||
type Cellule;
|
||||
type Lien is access Cellule;
|
||||
type Cellule is record
|
||||
Info : Element;
|
||||
Suiv : Lien;
|
||||
end record;
|
||||
|
||||
-- type liste ameliore : record contenant la liste et sa taille
|
||||
-- (evite de parcourir la liste pour calculer la taille)
|
||||
|
||||
type Une_Liste_Ordonnee is record
|
||||
Debut : Lien := null;
|
||||
Taille : Natural := 0;
|
||||
end record;
|
||||
end Liste_Ordonnee_Cle_G ;
|
|
@ -0,0 +1,14 @@
|
|||
Programme d'annuaire inversé - Version ABR
|
||||
Nom de l'annuaire:
|
||||
A_50000.txt
|
||||
Annuaire en mémoire.
|
||||
|
||||
Veillez saisir un numéro à rechercher:
|
||||
0765915625
|
||||
Recherche de 0765915625 dans l'arbre
|
||||
Entrée trouvée : Sharon Torres Besançon Psychiatre 0765915625;
|
||||
La recherche a durée : 0.000014000
|
||||
|
||||
Recherche dans la liste :
|
||||
Entrée trouvée : Sharon Torres Besançon Psychiatre 0765915625;
|
||||
La recherche a durée : 0.011632000
|
|
@ -0,0 +1,9 @@
|
|||
with Ada.Unchecked_Deallocation;
|
||||
|
||||
package Pointeurs_De_Strings is
|
||||
|
||||
type P_String is access String;
|
||||
|
||||
procedure Liberer_String is new Ada.Unchecked_Deallocation(String , P_String);
|
||||
|
||||
end Pointeurs_De_Strings;
|
未顯示二進位檔案。
|
@ -0,0 +1,65 @@
|
|||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
with Contact_Cle; use Contact_Cle;
|
||||
with Arbre_Bin_Recherche_Cle_G;
|
||||
|
||||
|
||||
procedure Tester_Abr_Contacts is
|
||||
|
||||
-- Instanciation du paquetage
|
||||
package Arbre_Contacts is new Arbre_Bin_Recherche_Cle_G(Un_Contact, Cle_contact, Cle, "<", "=", Liberer_Contact, Contact_To_string);
|
||||
use Arbre_Contacts;
|
||||
|
||||
|
||||
-- Variables pour la lecture du fichier annuaire
|
||||
Fichier : File_Type;
|
||||
Chaine, Ligne : String(1..80);
|
||||
Len, last : Integer := 0;
|
||||
AB : Arbre;
|
||||
C : Un_Contact;
|
||||
|
||||
Prenom, Nom, Ville, Specia, Telephone, Fin, I : Integer := 0;
|
||||
begin
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Utilisation d'annuaires
|
||||
-----------------------------------------------------------
|
||||
|
||||
-- Entourloupe pour avoir un nom de fichier contraint, saisi par l'utilisateur et de bonne taille
|
||||
Put_Line("Lecture d'un fichier de contact, veillez saisir le nom du fichier : ");
|
||||
Get_Line(Chaine, Len);
|
||||
declare
|
||||
Nom_Fichier : String(Chaine'First..Len) := Chaine(Chaine'First..Len);
|
||||
begin
|
||||
open(Fichier, in_File, "./jeux_de_donnees/" & Nom_Fichier);
|
||||
while not End_Of_File(Fichier) loop
|
||||
Get_Line (Fichier, Ligne , Len ) ;
|
||||
Put_Line ( "Ajouté à l'arbre: " & Ligne(1..Len));
|
||||
|
||||
Prenom := 1;
|
||||
Nom := 0;
|
||||
Ville := 0;
|
||||
Specia := 0;
|
||||
Telephone := 0;
|
||||
Fin := 0;
|
||||
I := 1;
|
||||
|
||||
while Telephone = 0 loop
|
||||
if Ligne(I) = ' ' then
|
||||
if Nom = 0 then Nom := I;
|
||||
elsif Ville = 0 then Ville := I;
|
||||
elsif Specia = 0 then Specia := I;
|
||||
elsif Telephone = 0 then Telephone := I; Fin := Telephone + 10;
|
||||
end if;
|
||||
end if;
|
||||
I := I + 1;
|
||||
end loop;
|
||||
C := Creer_Contact(Ligne(Prenom..Nom-1), Ligne(Nom+1..Ville-1), Ligne(Ville+1..Specia-1), Ligne(Specia+1..Telephone-1), Ligne(Telephone+1..Fin-1) & " ");
|
||||
Inserer(C, AB);
|
||||
end loop;
|
||||
Close(Fichier);
|
||||
|
||||
|
||||
Put_Line(Arbre_To_String(AB));
|
||||
end;
|
||||
|
||||
end Tester_Abr_Contacts;
|
未顯示二進位檔案。
本差異變更的檔案數量過多導致部分檔案未顯示 顯示更多
載入中…
新增問題並參考