Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- std::string odwrocenie(const std::string& slowo) {
- std::string result{};
- for (auto i{ static_cast<int>(slowo.size() - 1) }; i >= 0; --i) {
- result += slowo[i];
- }
- return result;
- }
- void odczytaj_i_zapisz() {
- std::ifstream plik{ "tekst.txt" };
- if (plik.fail()) {
- std::cout << "Blad odczytu!\n";
- return;
- }
- std::string slowo;
- while (plik >> slowo) {
- std::cout << odwrocenie(slowo) << ' ';
- }
- plik.close();
- std::cout << std::endl;
- }
- int main() {
- odczytaj_i_zapisz();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement