Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. bool czy_jednolite(std::string text1, std::string text2){
  6. if(text1.size() != text2.size())
  7. return 0;
  8. for(int i = 0; i < text1.size(); i++){
  9. if(text1[i] != text2[i] || text1[i] != text1[0])
  10. return 0;
  11. }
  12. return 1;
  13. }
  14.  
  15. std::string posortuj_anagram(std::string str, std::string zbior){
  16.  
  17. return str;
  18. }
  19.  
  20. bool czy_anagram(std::string text1, std::string text2){
  21. if(text1.size() != text2.size())
  22. return 0;
  23. std::string znaki = "ABCDEFGHIJ";
  24. int wartosci[znaki.size()];
  25. //////////////ZEROWANIE TABLICY///////////////////
  26. for(int i = 0; i < sizeof(wartosci)/sizeof(int); i++){
  27. wartosci[i] = 0;
  28. }
  29. //////////////////////////////////////////////////
  30. for(int i = 0; i < sizeof(wartosci)/sizeof(int); i++){
  31. for(int j = 0; j < text1.size(); j++){
  32. if(text1[j] == znaki[i]){
  33. wartosci[i] ++;
  34. }
  35. }
  36. }
  37. for(int i = 0; i < sizeof(wartosci)/sizeof(int); i++){
  38. for(int j = 0; j < text2.size(); j++){
  39. if(text2[j] == znaki[i]){
  40. if(wartosci[i] - 1 < 0)
  41. return 0;
  42. else
  43. wartosci[i]--;
  44. }
  45. }
  46. }
  47. int suma = 0;
  48. for(int i = 0; i < sizeof(wartosci)/sizeof(int); i++){
  49. suma += wartosci[i];
  50. }
  51. return !suma;
  52. }
  53.  
  54.  
  55. int main(){
  56. std::string stringi[2000];
  57. std::cout<<czy_anagram("ghg", "ggh")<<std::endl;
  58. std::cout<<czy_jednolite("dAA", "dAA");
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement