/** Computes the number of different groups of integers summing to value n
* @pre n is a non negative number.
* @post None.
* @param n The number specified by the user to calculate.
* @return The number of different groups of integers for the specified number. */
#include<iostream>
using namespace std;
int calculate (int n);
int main()
{
int n;
char y;
do
{
cout << "Enter a number to calculate the number of integer groups that sum to it: " << endl;
cin >> n;
if (n = 2)
{
cout << "With permutations: 1" << endl;
cout << "Without permutations: 1" << endl;
return 0;
}
if (n > 2)
{
calculate(n);
}
else
{
cerr << "Error: The number you entered is not valid." << endl;
return 1;
}
}while(n > 0);
return 0;
}
/** Computes the number of groups of integers for the specified number.
* @pre n must be greater than or equal to 2.
* @post None.
* @return The number of integer groups summing up to the value. */
int calculate (int n)
{
for (n = n, n-1 , --n)
{
}
return n;
}
cmel89 0 Newbie Poster
VernonDozier 2,218 Posting Expert Featured Poster
mrnutty 761 Senior Poster
cmel89 0 Newbie Poster
VernonDozier 2,218 Posting Expert Featured Poster
cmel89 0 Newbie Poster
Sky Diploma 571 Practically a Posting Shark
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.