Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- //#pragma warning(disable: 4996)
- void citire(int &n)
- {
- cin >> n;
- if (n <= 0)
- citire(n);
- }
- int cauta_val_existenta(int sir[], int val, int lung)//consideram sirul crescator
- {
- if (lung > 0 && val != sir[lung])
- return cauta_val_existenta(sir, val, lung - 1);
- if (lung == 0)
- return false;
- else
- return true;
- }
- void inserare_element_cresc(int sir[], int lung, int k)
- {
- if (lung > 0 && k < sir[lung])
- {
- sir[lung + 1] = sir[lung];
- inserare_element_cresc(sir, lung - 1, k);
- }
- else
- sir[lung + 1] = k;
- }
- void creare_multime(int multime[], int n, int &lung)
- {
- if (n > 0)
- {
- if (cauta_val_existenta(multime, n % 10, lung) == 0)
- {
- inserare_element_cresc(multime, lung, n % 10);
- lung++;
- }
- creare_multime(multime, n / 10, lung );
- }
- }
- void afisare(int multime[], int lung)
- {
- if (lung > 0)
- {
- afisare(multime, lung - 1);
- cout << multime[lung] << " ";
- }
- else
- cout << "multimea n:";
- }
- int main()
- {
- int n, multime[10], lung = 0;
- citire(n);
- creare_multime(multime, n, lung);
- afisare(multime, lung);
- cout << endl << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement