.................................................. .................................................. ...................
Expand|Select|Wrap|Line Numbers
- #include <time.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <conio.h>
- #include <iostream>
- #include <string.h>
- using namespace std;
- char reply='y';
- int j=0;
- main()
- {
- while(reply=='y')
- {
- char s[3];
- char r[6][4];
- char arr[6][4];
- cout<<"\nenter the 4 letter word";
- cin>>s;
- cout<<"\nthe 1st letter is\t"<<s[0]<<"\n";
- cout<<"\nthe 2nd letter is\t"<<s[1]<<"\n";
- cout<<"\nthe 3rd letter is\t"<<s[2]<<"\n";
- cout<<"\nthe 4th letter is\t"<<s[3]<<"\n";
- cout<<"\n\n";
- int rolls=24;
- srand((unsigned int)time((time_t *)NULL));
- cout<<"\nthe possible allel combinations are \n\n"<<"\n";
- int a=1;
- int b=1;
- while(rolls--)
- {
- int i=((rand()%4)+0);
- if(i==0)
- {
- r[b][a]=s[0];
- arr[b][a]=s[0];
- cout<<r[b][a];
- }
- else
- if(i==1)
- {
- r[b][a]=s[1];
- arr[b][a]=s[1];
- cout<<r[b][a];
- }
- else
- if(i==2)
- {
- r[b][a]=s[2];
- arr[b][a]=s[2];
- cout<<r[b][a];
- }
- else
- if(i==3)
- {
- r[b][a]=s[3];
- arr[b][a]=s[3];
- cout<<r[b][a];
- }
- a++;
- if(a>4)
- {
- a=1;
- b++;
- }
- j++;
- if(j==4)
- {
- printf(" \n\n");
- j=0;
- }
- }
- // crossover
- cout<<"\n\n after cross over\n\n";
- arr[1][3]=r[2][3];
- arr[1][4]=r[2][4];
- arr[2][3]=r[1][3];
- arr[2][4]=r[1][4];
- arr[3][3]=r[4][3];
- arr[3][4]=r[4][4];
- arr[4][3]=r[3][3];
- arr[4][4]=r[3][4];
- arr[5][3]=r[6][3];
- arr[5][4]=r[6][4];
- arr[6][3]=r[5][3];
- arr[6][4]=r[5][4];
- int h=0;
- int m=1;
- int n=1;
- int roll=24;
- while(roll--)
- {
- cout<<arr[m][n];
- n++;
- if(n>4)
- {
- n=1;
- m++;
- }
- h++;
- if(h==4)
- {
- printf(" \n\n");
- h=0;
- }
- }
cout<<"want to try again ? (y/n)";
cin>>reply;
}
getch();
}
------------------------------------------------------------------------------------------------------------------
anagrams.txt
---------------------------------------------
Expand|Select|Wrap|Line Numbers
- abed
- bade
- bead
- abet
- beat
- beta
- abut
- tabu
- tuba
- acme
- came
- mace
- acre
- care
- race
- ales
- leas
- sale
- seal
- amen
- mane
- mean
- name
- anew
- wane
- wean
- arcs
- cars
- scar
- asps
- pass
- saps
- spas
- awls
- laws
- slaw
- bard
- brad
- drab
- bats
- stab
- tabs
- brag
- garb
- grab
- code
- coed
- deco
- dale
- deal
- lade
- lead
- dare
- dear
- read
- diet
- edit
- tide
- tied
- demo
- dome
- mode
- diet
- edit
- tide
- tied
- does
- dose
- odes
- dues
- sued
- used
- ears
- eras
- sear
- rose
- sore
- ores