Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3.  
  4. using namespace std;
  5.  
  6. main()
  7. {
  8. ifstream plik("dane_geny.txt");
  9. string osobnik;
  10. int gatunki[501];
  11. string osobniki[1000];
  12. int maks=0;
  13. int maksGat=0;
  14. int lGat=0;
  15. string geny;
  16. int ilMut=0;
  17.  
  18. for(int i=0; i<501; i++) gatunki[i]=0;
  19. for(int i=0; i<1000; i++)
  20. {
  21. plik>>osobnik;
  22. gatunki[osobnik.length()]++;
  23. osobniki[i]=osobnik;
  24. if(gatunki[osobnik.length()]>maks)
  25. {
  26. maks=gatunki[osobnik.length()];
  27. maksGat=osobnik.length();
  28. }
  29. }
  30. for(int i=0; i<501; i++)
  31. {
  32. if(gatunki[i] != 0) lGat += 1;
  33. }
  34. //cout << "najliczniejszy gatunek to " << maksGat << " o ilosci osobnikow rownej " << maks << endl << "wszystkich gatunkow jest " << lGat;
  35. /*for(int i=0; i<1000; i++)
  36. {
  37. cout << i+1 << "\t" << osobniki[i] << endl;
  38. }*/
  39. for(int i=0; i<1000; i++)
  40. {
  41. osobnik = osobniki[i];
  42. cout << "osobnik: " << i+1 << "\t" << osobnik << endl;
  43. for(int j=0; j<osobnik.length()-1; j++)
  44. {
  45. if(osobnik[j]=='A' && osobnik[j+1]=='A')
  46. {
  47. geny="";
  48. for(int k=j; k<osobnik.length()-1; k++)
  49. {
  50. geny+=osobnik[k];
  51. if(osobnik[k]=='B' && osobnik[k+1]=='C' && osobnik[k+2]=='D' && osobnik[k+3]=='D' && osobnik[k+4]=='C') ilMut+=1;
  52.  
  53. if(osobnik[k]=='B' && osobnik[k+1]=='B')
  54. {
  55. geny+=osobnik[k+1];
  56. j=k+2;
  57. cout << "\""<< geny << "\""<< endl;
  58. break;
  59. }
  60. }
  61. }
  62.  
  63. }
  64. }
  65. cout << "ilosc zmutowanych zolwi ninja " << ilMut;
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement