Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <ctime>
- #include <cstdlib>
- #include <cstring>
- #include <string>
- using namespace std;
- int main() {
- setlocale(0,"");
- int b;
- string s,a,A;
- lab:
- cout<<"Введите строку:"<<endl;
- getline(cin,s);
- cout<<endl<<"Что найти?"<<endl;
- getline(cin,a);
- cout<<endl<<"На что заменить?"<<endl;
- getline(cin,A);
- b=A.length();
- if (s.find(a) == std::string::npos ) {cout<<"Такого символа(ов) нет!"<<endl;}
- else do {s.replace(s.find(a),b,A);} while (s.find('a') != std::string::npos);
- cout<<endl<<"Вот, что получилось:"<<endl<<s<<endl<<endl<<"Повторим? Если нет - введите 0. Иначе - любой другой символ"<<endl;
- cin>>b;
- if (b==0) return 0;
- else {system("cls");system("clean"); goto lab;}
- }
- ___________________
- #include <iostream>
- #include <cmath>
- #include <ctime>
- #include <cstdlib>
- #include <cstring>
- #include <string>
- using namespace std;
- int main() {
- setlocale(0,"");
- srand(time(0));
- int n;
- string s;
- cout<<"Введите количество строк"<<endl;
- cin>>n;
- const int str=n+1;
- string ar[str];
- cout<<"Вводите строки:"<<endl;
- for (int i=0;i<str;i++){
- getline(cin,s);
- ar[i]=s;
- }
- cout<<endl<<"Теперь мы отсортируем их по алфавиту:"<<endl;
- }
- _______________________________________--
- #include <iostream>
- #include <cmath>
- #include <ctime>
- #include <cstdlib>
- #include <cstring>
- #include <string>
- using namespace std;
- int main() {
- setlocale(0,"");
- srand(time(0));
- int n;
- string s;
- cout<<"Введите количество строк"<<endl;
- cin>>n;
- const int str=n+1;
- string ar[str];
- cout<<"Вводите строки:"<<endl;
- for (int i=0;i<str;i++){
- getline(cin,s);
- ar[i]=s;
- }
- cout<<endl<<"Теперь мы отсортируем их по алфавиту:"<<endl;
- }
- ___________________________________________________
- #include <iostream>
- #include <cmath>
- #include <ctime>
- #include <cstdlib>
- #include <cstring>
- #include <string>
- using namespace std;
- int main() {
- setlocale(0,"");
- srand(time(0));
- string s;
- cout<<"Введите строку:"<<endl;
- getline(cin,s);
- int d=s.length();
- while (s[0]==' ') s.erase(0,1);
- for (int i=0;i<d;i++){
- if ((s[i]==' ')&&(s[i+1]==' ')){
- s.erase(i,1);
- i--;}
- }
- cout<<endl<<"Исправленный вариант:"<<endl<<s<<endl;
- }
- ________________________________________________________
- #include <iostream>
- #include <cmath>
- #include <ctime>
- #include <cstdlib>
- #include <cstring>
- #include <string>
- using namespace std;
- int main() {
- setlocale(0,"");
- srand(time(0));
- string s;
- cout<<"Введите слово из 5 букв:"<<endl;
- lab:
- getline(cin,s);
- if (s.length()!=5) {cout<<endl<<"Ошибка! Введите слово из пяти букв!"<<endl; goto lab;}
- 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){
- 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)
- cout<<endl<<"ВОТ ЭТО ПОЛИНДРОМ!"<<endl;}
- else cout<<endl<<"Не, не он."<<endl;
- goto lab;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement