Advertisement
Wooph

ProdusCartezian1

Feb 25th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include<fstream>
  2. #include <iostream>
  3. #include<math.h>
  4. #include<cstring>
  5. using namespace std;
  6. ifstream fin("produscartezian1.in");
  7. ofstream fout("produscartezian1.out");
  8. int st[10],n,m;
  9. void afisare_stiva()
  10. {
  11.     int i;
  12.     for(i=1; i<=m; i++)         fout<<st[i]<<" ";
  13.     fout<<endl;
  14. }
  15. void back(int nivel)
  16. {
  17.     if(nivel>m) afisare_stiva();
  18.     else
  19.     {
  20.         for(int i=1; i<=n; i++)
  21.         {
  22.             st[nivel]=i;
  23.             back(nivel+1);
  24.         }
  25.     }
  26. }
  27. int main ()
  28. {
  29.     fin>>n>>m;
  30.     back(1);
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement