Advertisement
Guest User

zad3_prawidlowe

a guest
Oct 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. // ConsoleApplication3.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include<iostream>
  6. #include<string>
  7. #include<fstream>
  8. using namespace std;
  9.  
  10.  
  11.  
  12. int main()
  13. {
  14.     int i;
  15.     int c=0;
  16.     string p= "Congratulations Mrs. <name>, you and Mr. <name> are the lucky recipients of a trip to XXXXXX. Your trip to XXX is already scheduled.";
  17.     int pos = p.find("<name>",0);
  18.  
  19.     p.replace(pos, 6, "Smith");
  20.  
  21.     pos = p.find("<name>", 0);
  22.     p.replace(pos, 6, "Smith");
  23.  
  24.     int pos2 = p.find("X", 0);
  25.     for (i = pos2; p[i]=='X'; i++){
  26.             c++;
  27.         }
  28.    
  29.     cout << c;
  30.     p.erase(pos2, c);
  31.     p.insert(pos2, "Siberia");
  32.    
  33.     /////
  34.     pos2 = p.find("X", 0);
  35.     for (i = pos2; p[i] == 'X'; i++){
  36.         c++;
  37.     }
  38.  
  39.     cout << c;
  40.     p.erase(pos2, c);
  41.     p.insert(pos2, "Siberia");
  42.  
  43.  
  44.     cout << p;
  45.  
  46.  
  47.     system("pause");
  48.     return 0;
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement