Arkanium77

Untitled

Feb 26th, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <ctime>
  5. #include <cstring>
  6.  
  7. using namespace std;
  8.  
  9. int main(){
  10. srand(time(0));
  11. setlocale(0,"");
  12. action:
  13. int n=0;
  14. char s='0';
  15. char *v;
  16. char s1[]="Hello World! ";
  17. char s2[]="Good Game, Well Played.";
  18. cout<<"Вот две строки:"<<endl<<s1<<endl<<s2<<endl;
  19. lab:
  20. cout<<endl<<"Чего желаете?"<<endl<<"ВНИМАНИЕ! ВСЕ, ЧТО ВЫ СДЕЛАЕТЕ - СОХРАНИТСЯ! ДЛЯ ОБНУЛЕНИЯ ВВЕДИТЕ 00"<<endl
  21. <<"1)Вычислить длину"<<endl<<"2)Выполнить конкатекацию"<<endl<<"3)Выполнить копирование s2 в s1"<<endl<<"4)Копирование n символов из s2 в s1"
  22. <<endl<<"5)Сравнить S1 и S2"<<endl<<"6)Выполнить поиск элемента в s1"<<endl;
  23. cin>>n;
  24. cout<<endl;
  25. switch (n){
  26. case 1: {cout<<endl<<"Длина строки."<<endl<<"S1 - "<<strlen(s1)<<endl<<"S2 - "<<strlen(s2)<<endl
  27. <<endl; goto lab;}
  28. case 2: {strcat(s1,s2); cout<<endl<<"S1:"<<s1<<endl<<"S2"<<s2<<endl;goto lab;}
  29. case 3: {strcpy(s1,s2); cout<<endl<<"Вот, что получилось:"<<endl<<"S1:"<<s1<<endl<<"S2:"<<s2<<endl;goto lab;}
  30. case 4: {cout<<endl<<"Сколько символов скопировать?"<<endl; cin>>n;strncpy(s1,s2,n); cout<<endl<<endl
  31. <<"S1:"<<s1<<endl<<"S2:"<<s2<<endl;goto lab;}
  32. case 5: {strcmp(s1,s2); goto lab;}
  33. case 6: {cout<<endl<<"Что вы хотите найти?"<<endl; cin>>s; v=strchr(s1,s);
  34. if (v==NULL)
  35. cout<<endl<<"Нет такого символа!"<<endl;
  36. else cout<<endl<<"Такой символ есть! "<<*v<<endl;
  37. goto lab;}
  38.  
  39. case 00: {system("clear"); goto action;}
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment