Загрузка...

Flip text C++

Thread in C/C++ created by FlyamCode May 27, 2019. 289 views

  1. FlyamCode
    FlyamCode Topic starter May 27, 2019 0 Jun 25, 2018
    #include <iostream>
    #include <string>


    using namespace std;
    int main()
    {
    string txt;
    cout << "Enter text that you need to reverse.\n" << "Write without spaces!\n";
    cin >> txt;
    int txtl = txt.length();

    do {
    txtl--;
    char txrd = txt.back();
    cout << txrd;
    txt.pop_back();

    } while (txtl >= 1);
    }
     
  2. SaintMurder_inactive629492
    эх,и для какой цели создана эта тема?
     
  3. mrros
    mrros May 27, 2019 19 Apr 15, 2019
    СМС БОМБЕР перевернутий?
     
  4. de9x
    de9x May 27, 2019 Frontend developer 141 Jan 3, 2019
    а без функций стандартной библиотеки, не включай cout & cin?
     
  5. de9x
    de9x May 27, 2019 Frontend developer 141 Jan 3, 2019
    допустим, в приложении ты реализуешь данный алогоритм, ты так же будешь пользователя просить ввести текст без пробелов ?? я б такого разработчика послал и удалил бы приложение нахуй
     
  6. ZLOYSERGUNYA
    ZLOYSERGUNYA May 27, 2019 save what remains 787 Jan 4, 2017
    reverse(str.begin(), str.end());

    где str — это строка типа string
     
  7. de9x
    de9x May 27, 2019 Frontend developer 141 Jan 3, 2019
    Code

    #include <iostream>
    #include <string>

    using namespace std;

    int main()
    {
    string text = "Hello, world!";
    int i, j, tmp;
    j = text.length() - 1;
    for(i = 0, j; i <= j; i++, j--)
    {
    tmp = text[i];
    text[i] = text[j];
    text[j] = tmp;
    }
    cout << text;
    }

     
Loading...
Top