Advertisement
Guest User

steaguri

a guest
Feb 26th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <iomanip>
  4. using namespace std;
  5. char culoare[7][20];
  6. int st[200];
  7. int k;
  8. void add ()
  9. {
  10. strcpy (culoare[1], "galben");
  11. strcpy (culoare[2], "rosu");
  12. strcpy (culoare[3], "verde");
  13. strcpy (culoare[4], "albastru");
  14. strcpy (culoare[5], "alb");
  15. strcpy (culoare[6], "negru");
  16. }
  17. int sol ()
  18. {
  19. return (k==3);
  20. }
  21. void tipar ()
  22. {
  23. for (int j=1; j<=k; j++)
  24. cout << setw(10)<<culoare[st[j]]<< " ";
  25. cout << endl;
  26. }
  27. int validare ()
  28. {
  29. if (k==2)
  30. if ( (st[k]!=3)&&(st[k]!=1))
  31. return 0;
  32. for (int i=1; i<=k-1; i++)
  33. if (st[k]==st[i])
  34. return 0;
  35. return 1;
  36.  
  37. }
  38. void bt ()
  39. {
  40. for (k=1; k<=6; k++)
  41. st[k]=0;
  42. k=1;
  43. while (k>0)
  44. {
  45. while (st[k]<6)
  46. {
  47. st[k] ++;
  48. if (validare()){
  49. if (sol())
  50. tipar ();
  51. else
  52. k++;}
  53. }
  54. st[k--]=0;
  55. }
  56. }
  57. int main ()
  58. {
  59. add();
  60. bt ();
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement