Advertisement
Arkanium77

Untitled

Mar 11th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <ctime>
  4. #include <cstdlib>
  5. #include <cstring>
  6. #include <string>
  7.  
  8.  
  9. using namespace std;
  10.  
  11. int main() {
  12. setlocale(0,"");
  13. int b;
  14. string s,a,A;
  15. lab:
  16. cout<<"Введите строку:"<<endl;
  17. getline(cin,s);
  18. cout<<endl<<"Что найти?"<<endl;
  19. getline(cin,a);
  20. cout<<endl<<"На что заменить?"<<endl;
  21. getline(cin,A);
  22.  
  23. b=A.length();
  24.  
  25. if (s.find(a) == std::string::npos ) {cout<<"Такого символа(ов) нет!"<<endl;}
  26. else do {s.replace(s.find(a),b,A);} while (s.find('a') != std::string::npos);
  27.  
  28. cout<<endl<<"Вот, что получилось:"<<endl<<s<<endl<<endl<<"Повторим? Если нет - введите 0. Иначе - любой другой символ"<<endl;
  29. cin>>b;
  30. if (b==0) return 0;
  31. else {system("cls");system("clean"); goto lab;}
  32. }
  33.  
  34. ___________________
  35.  
  36. #include <iostream>
  37. #include <cmath>
  38. #include <ctime>
  39. #include <cstdlib>
  40. #include <cstring>
  41. #include <string>
  42.  
  43.  
  44. using namespace std;
  45.  
  46. int main() {
  47. setlocale(0,"");
  48. srand(time(0));
  49. int n;
  50. string s;
  51. cout<<"Введите количество строк"<<endl;
  52. cin>>n;
  53.  
  54. const int str=n+1;
  55.  
  56. string ar[str];
  57.  
  58. cout<<"Вводите строки:"<<endl;
  59. for (int i=0;i<str;i++){
  60. getline(cin,s);
  61. ar[i]=s;
  62. }
  63.  
  64. cout<<endl<<"Теперь мы отсортируем их по алфавиту:"<<endl;
  65. }
  66.  
  67. _______________________________________--
  68.  
  69. #include <iostream>
  70. #include <cmath>
  71. #include <ctime>
  72. #include <cstdlib>
  73. #include <cstring>
  74. #include <string>
  75.  
  76.  
  77. using namespace std;
  78.  
  79. int main() {
  80. setlocale(0,"");
  81. srand(time(0));
  82. int n;
  83. string s;
  84. cout<<"Введите количество строк"<<endl;
  85. cin>>n;
  86.  
  87. const int str=n+1;
  88.  
  89. string ar[str];
  90.  
  91. cout<<"Вводите строки:"<<endl;
  92. for (int i=0;i<str;i++){
  93. getline(cin,s);
  94. ar[i]=s;
  95. }
  96.  
  97. cout<<endl<<"Теперь мы отсортируем их по алфавиту:"<<endl;
  98. }
  99.  
  100. ___________________________________________________
  101.  
  102. #include <iostream>
  103. #include <cmath>
  104. #include <ctime>
  105. #include <cstdlib>
  106. #include <cstring>
  107. #include <string>
  108.  
  109.  
  110. using namespace std;
  111.  
  112. int main() {
  113. setlocale(0,"");
  114. srand(time(0));
  115. string s;
  116. cout<<"Введите строку:"<<endl;
  117. getline(cin,s);
  118. int d=s.length();
  119. while (s[0]==' ') s.erase(0,1);
  120. for (int i=0;i<d;i++){
  121. if ((s[i]==' ')&&(s[i+1]==' ')){
  122. s.erase(i,1);
  123. i--;}
  124. }
  125. cout<<endl<<"Исправленный вариант:"<<endl<<s<<endl;
  126. }
  127.  
  128. ________________________________________________________
  129.  
  130. #include <iostream>
  131. #include <cmath>
  132. #include <ctime>
  133. #include <cstdlib>
  134. #include <cstring>
  135. #include <string>
  136.  
  137.  
  138. using namespace std;
  139.  
  140. int main() {
  141. setlocale(0,"");
  142. srand(time(0));
  143. string s;
  144. cout<<"Введите слово из 5 букв:"<<endl;
  145. lab:
  146. getline(cin,s);
  147. if (s.length()!=5) {cout<<endl<<"Ошибка! Введите слово из пяти букв!"<<endl; goto lab;}
  148. if (s[0]==s[4]||s[0]+33==s[4]||s[0]-33==s[4]||s[0]==s[4]+33||s[0]==s[4]-33){
  149. if (s[1]==s[3]||s[1]+33==s[3]||s[1]-33==s[3]||s[1]==s[3]+33||s[1]==s[3]-33)
  150. cout<<endl<<"ВОТ ЭТО ПОЛИНДРОМ!"<<endl;}
  151. else cout<<endl<<"Не, не он."<<endl;
  152. goto lab;
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement