Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- char sp4[] = "";
- int x4[20], n4, nrsol4 = 0, a[20];
- void Afisare4() {
- int i, j;
- cout << sp4;
- for (i = 1; i <= n4; i++) cout << x4[i] << " ";
- cout << endl;
- nrsol4++;
- }
- void BackRec4(int k) {
- int i;
- for (i = 1; i <= a[k]; i++) {
- x4[k] = i;
- if (k == n4)
- Afisare4();
- else
- BackRec4(k + 1);
- }
- }
- int main() {
- int i;
- cout << endl
- << endl
- << sp4 << "Produsul cartezian a n multimi de cardinal a1, a2, ... an"
- << endl;
- cout << endl << sp4 << " Dati valoarea lui n: ";
- cin >> n4;
- cout << endl << sp4 << " Dati cardinalul fiecarei multimi: " << endl << endl;
- for (i = 1; i <= n4; i++) {
- cout << sp4 << " Multimea " << i << ": ";
- cin >> a[i];
- }
- BackRec4(1);
- cout << endl << sp4 << "Numar solutii: " << nrsol4;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement