Advertisement
piotrek32110

lab3

Dec 8th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.93 KB | None | 0 0
  1. // lab3.cpp : Ten plik zawiera funkcję „main”. W nim rozpoczyna się i kończy wykonywanie programu.
  2. //
  3.  
  4. #include <iostream>
  5. #include <fstream>
  6. #include <string>
  7. using namespace std;
  8. string string_reverse(const string& in)
  9. {
  10.     string copyin;
  11.     copyin = in;
  12.     for (unsigned int i = 0; i < in.size(); i++)
  13.     {
  14.         copyin[i] = in[in.size() - 1 - i];
  15.     }
  16.     return copyin;
  17. }
  18. bool is_clic(const string& str1, const string& str2)
  19. {
  20.     string str1c = str1;
  21.     string str2c = str2;
  22.     for (int i = 0; i < sizeof(str1); i++)
  23.     {
  24.         str1c.insert(0, str1c, str1c.size() - 1, 1);
  25.         str1c.pop_back();
  26.         if (str1c == str2c)
  27.             return true;
  28.  
  29.  
  30.     }
  31.     return false;
  32. }
  33.  
  34. int main()
  35. {
  36.     string str1;
  37.     int numb = 0;
  38.     getline(cin, str1);
  39.     for (unsigned int i = 0; i < str1.size(); i++)
  40.     {
  41.         if (isdigit(str1[i]) > 0)
  42.             numb++;
  43.     }
  44.     cout << "Ilosc cyfr to " << numb << endl;
  45.  
  46.     ifstream file("C:/plik.txt");
  47.     string line;
  48.     if (file.is_open())
  49.     {
  50.         while (getline(file, line))
  51.         {
  52.             cout << string_reverse(line) << endl;
  53.         }
  54.         file.close();
  55.     }
  56.     string third = "Congratulations Mrs. <name>, you and Mr. <name> are the lucky recipients of a trip for two to XXXXXX. Your trip to XXX is already scheduled ";
  57.     string iks = "X";
  58.     string nazwa = "<name>";
  59.     int lengthx = 0;
  60.     while(third.find(nazwa) != -1)
  61.         third.replace(third.find(nazwa),nazwa.size() , "Smith");
  62.     while (third.find("X") != -1)
  63.     {
  64.         cout << "Test1" << endl;
  65.         cout << third[third.find(iks) + lengthx + 1] << endl;
  66.         if (third[third.find(iks) + lengthx + 1] != 'X')
  67.         {
  68.             third.replace(third.find(iks), lengthx + 1, "Siberia");
  69.             lengthx = 0;
  70.             cout << "Test" << endl;
  71.             continue;
  72.         }
  73.         lengthx++;
  74.     }
  75.     if(third.find("lucky") != -1)
  76.     {
  77.         third.insert(third.find("lucky"), "un");
  78.     }
  79.  
  80.     cout << third << endl;
  81.  
  82.     string testing = "Test";
  83.     testing.pop_back();
  84.     testing.insert(1, "dasdsd");
  85.     cout << testing << endl;
  86.     string str11 = "ACTGACG";
  87.     string str22 = "TGACGAC";
  88.     cout << "Test asd " << is_clic(str11, str22) << endl;
  89.  
  90.     char testing1;
  91.     cin >> testing1;
  92.  
  93.     switch (testing1)
  94.     {
  95.     case 'a':
  96.         cout << "Test";
  97.         break;
  98.     }
  99.  
  100.  
  101. }
  102.  
  103. // Uruchomienie programu: Ctrl + F5 lub menu Debugowanie > Uruchom bez debugowania
  104. // Debugowanie programu: F5 lub menu Debugowanie > Rozpocznij debugowanie
  105.  
  106. // Porady dotyczące rozpoczynania pracy:
  107. //   1. Użyj okna Eksploratora rozwiązań, aby dodać pliki i zarządzać nimi
  108. //   2. Użyj okna programu Team Explorer, aby nawiązać połączenie z kontrolą źródła
  109. //   3. Użyj okna Dane wyjściowe, aby sprawdzić dane wyjściowe kompilacji i inne komunikaty
  110. //   4. Użyj okna Lista błędów, aby zobaczyć błędy
  111. //   5. Wybierz pozycję Projekt > Dodaj nowy element, aby utworzyć nowe pliki kodu, lub wybierz pozycję Projekt > Dodaj istniejący element, aby dodać istniejące pliku kodu do projektu
  112. //   6. Aby w przyszłości ponownie otworzyć ten projekt, przejdź do pozycji Plik > Otwórz > Projekt i wybierz plik sln
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement