Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstring>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- ofstream fout("iesire.txt");
- char culoare[7][20];
- int st[200];
- int k;
- void add ()
- {
- strcpy (culoare[1], "galben");
- strcpy (culoare[2], "rosu");
- strcpy (culoare[3], "verde");
- strcpy (culoare[4], "albastru");
- strcpy (culoare[5], "alb");
- strcpy (culoare[6], "negru");
- }
- int sol ()
- {
- return (k==3);
- }
- void tipar ()
- {
- for (int j=1; j<=k; j++)
- fout << setw(10)<<culoare[st[j]]<< " ";
- fout << endl;
- }
- int validare ()
- {
- if (k==2)
- if ( (st[k]!=3)&&(st[k]!=1))
- return 0;
- for (int i=1; i<=k-1; i++)
- if (st[k]==st[i])
- return 0;
- return 1;
- }
- void bt ()
- {
- for (k=1; k<=6; k++)
- st[k]=0;
- k=1;
- while (k>0)
- {
- while (st[k]<6)
- {
- st[k] ++;
- if (validare()){
- if (sol())
- tipar ();
- else
- k++;}
- }
- st[k--]=0;
- }
- }
- int main ()
- {
- add();
- bt ();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement