Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <locale.h>
  4. #include <iostream>
  5. #include <stdlib.h>
  6. #include <string.h>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. setlocale(0, "russian");
  13. char** strs = new char* [30];
  14. for (int i = 0;i < 30;i++){
  15. strs[i] = new char [80];
  16. }
  17. char* ptr1;
  18. char* str = new char [80];
  19. printf("Введите строку,содержащую '*' :\n");
  20. int l = 0;
  21. gets(str);
  22. while(strlen(str) != 0){
  23. strcpy(*(strs + l++),str);
  24. gets(str);
  25. }
  26. char* s2=new char[80];
  27. for(int i = 0; i < l;i++) {
  28. char *c1 = strs[i];
  29. ptr1 = strs[i];
  30. printf("Адреса найденных символов '*' \n");
  31. while (*c1 != '\0') {
  32. if (*c1 == '*') {
  33. cout << *c1 << " " << (void *) c1 << " ";
  34. printf("\n");
  35. }
  36. c1++;
  37. }
  38. printf("Полученная строка,путем удвоения '*' :\n");
  39. while (ptr1 = strstr(ptr1, "*"), ptr1 != NULL) {
  40. strcpy(s2, ptr1);
  41. strcpy((ptr1 + 1), s2);
  42. ptr1 = ptr1 + 2;
  43. }
  44. puts(strs[i]);
  45. }
  46.  
  47. for(int i = 0;i < l;i++){
  48. cout << strs[i] << endl;
  49. }
  50. for(int i = 0;i < l;i++){
  51. delete [] strs[i];
  52. }
  53. delete [] strs;
  54. delete[] s2;
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement