Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <stdlib.h>
  5. #include <math.h>
  6. #include <sstream>
  7. using namespace std;
  8.  
  9.  
  10. int main()
  11. {
  12. fstream otworz;
  13. otworz.open("sygnaly.txt", ios::in);
  14. string linia;
  15. int licznikSame = 0;
  16. int licznikRozne = 0;
  17. string slowo;
  18. int maxx = 0;
  19. bool czyMniejszerowne10 = true;
  20. while(!otworz.eof())
  21. {
  22. otworz >> linia;
  23. for(char i = 0; i < linia.length(); i++)
  24. {
  25. for(int j = 0; j < linia.length(); j++)
  26. {
  27. if((abs((int)linia[i]-(int)linia[j])) > 10)
  28. {
  29. czyMniejszerowne10 = false;
  30. }
  31. }
  32. }
  33. if(czyMniejszerowne10 == true) cout << linia << endl;
  34. czyMniejszerowne10 = true;
  35. }
  36.  
  37. return 0;
  38. }
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. /*int main()
  52. {
  53. fstream otworz;
  54. otworz.open("sygnaly.txt", ios::in);
  55. string linia;
  56. int licznikSame = 0;
  57. int licznikRozne = 0;
  58. string slowo;
  59. int maxx = 0;
  60. while(!otworz.eof())
  61. {
  62. otworz >> linia;
  63. for(char i = 'A'; i <= 'Z'; i++)
  64. {
  65. for(int j = 0; j < linia.length(); j++)
  66. {
  67. if(linia[j] == i) licznikSame+=1;
  68. }
  69. if(licznikSame > 0) licznikRozne+=1;
  70. licznikSame = 0;
  71. }
  72. if(licznikRozne > maxx)
  73. {
  74. slowo = linia;
  75. maxx = licznikRozne;
  76. }
  77. //cout << linia << " ";
  78. //cout << licznikRozne << endl;
  79. licznikRozne = 0;
  80. }
  81.  
  82.  
  83. cout << slowo << " ";
  84. cout << maxx << endl;
  85.  
  86. return 0;
  87. }*/
  88.  
  89.  
  90.  
  91. /*int main()
  92. {
  93. fstream otworz;
  94. otworz.open("sygnaly.txt", ios::in);
  95. string linia;
  96. int licznik = 1;
  97. string slowo = "";
  98. while(!otworz.eof())
  99. {
  100. otworz >> linia;
  101. if(licznik%40 == 0) slowo+=linia[9];
  102. licznik++;
  103.  
  104. }
  105. cout << slowo;
  106. return 0;
  107. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement