Texas A M University Permutations and Combinations Algorithms Worksheet
Programming Assignment 4NAME _____________________________
Turned in April 25 11am: on Time ______________
Turned in:
Printout of .cpp file for program 4
Printout of input files (2)
Solution / Used Concepts Discussed in Class:
Opens input and output files
Closes input and output files
Uses while !eof loop to read list
Used Iterative Factorial function for
Perm
User Interface (I/O Formatting):
Reads number of test cases
Asked user for name of files
Printed heading (name and program)
Prints number of test cases
Readability/Algorithm/Style
Good comments
• Top of every file
• Prototypes for methods/functions
• Internal code
Good use of blank lines/spacing in
program
Sample Output corresponding to Input file
Antonio Martin
CMPS 2433 Program 4
P
C
C
P
P
P
C
(5, 2) =
(10,3) =
(10,7) =
(20,20) =
(5, 1) =
(3, 0) =
(9, 9) =
20
120
120
2432902008176640000
5
1
1
__________/ 100 points
Printout of output files (2)
Used Recursive Factorial for Combo
Computes Permutations correctly
Computes Combinations correctly
Labels columns
Numbers lined up
Used blank lines and spacing (pretty)
Good choice of identifiers
Good indentation
Good choice of control structures (ie
switches, loops, etc.)
Has 5 or more functions
CMPS 2433 Discrete Structures and Analysis
Program 4 Spring 2022
Due Monday, April 25, 2022
PURPOSE: To reinforce the concepts of the Permutations and Combinations algorithms.
PROBLEM: For this program, you will read in data from the input file. You will calculate the number of
permutations or combinations. The first character on a line will be either a P or a C. After that will be 2
integers n (1 ≤ n ≤ 60). No need for input validation. No solutions will have more than 16 significant
digits. For each line of input data, output the correct result.
Sample input file:
Sample output:
P 5 2
C 10 3
P 20 20
Antonio Martin
CMPS 2433 Program 4
P (5, 2) =
C (10,3) =
P (20,20) =
20
120
2432902008176640000
REQUIREMENTS:
•
Read from the input file until the end of file is reached. As always, the input file, source code, and
output files will be in the same directory.
•
Display your name and the assignment at the top of the output file.
•
Display all results as whole numbers (no digits behind the decimal point and no scientific notation).
•
You must write 2 factorial functions. One must be iterative and the other recursive. Use one when
you calculate permutations and the other when you calculate combinations.
TURN IN (upload to D2L)
•
•
•
2 input files: prog4.dat and prog4mine.dat
2 output files: lastname_combo1.txt and lastname_combon2.txt
source code name: lastname_combo.cpp
Top-quality papers guaranteed
100% original papers
We sell only unique pieces of writing completed according to your demands.
Confidential service
We use security encryption to keep your personal data protected.
Money-back guarantee
We can give your money back if something goes wrong with your order.
Enjoy the free features we offer to everyone
-
Title page
Get a free title page formatted according to the specifics of your particular style.
-
Custom formatting
Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.
-
Bibliography page
Don’t pay extra for a list of references that perfectly fits your academic needs.
-
24/7 support assistance
Ask us a question anytime you need to—we don’t charge extra for supporting you!
Calculate how much your essay costs
What we are popular for
- English 101
- History
- Business Studies
- Management
- Literature
- Composition
- Psychology
- Philosophy
- Marketing
- Economics