Загрузка...

Why is everything executed except for the first word?

Thread in C/C++ created by hokage Oct 21, 2021. 227 views

  1. hokage
    hokage Topic starter Oct 21, 2021 pentester 1026 Jun 15, 2020
    Code
    #include <iostream>
    #include <string.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>

    using namespace std;
    int main() {
    setlocale(0, "");
    int i = 0, j = 0, len;
    char q[1000];
    char* result;
    char s;
    gets_s(q);
    result = strtok(q," ,.-");
    memset(result, '\0', sizeof(result));
    while (result != NULL) {
    s = result[strlen(result)-1];
    result[strlen(result)-1] = result[0];
    result[0] = s;
    cout << result;
    result = strtok(NULL," ,.-");
    }



    }
    [IMG]
    Consol
     
  2. kageno
    kageno Oct 21, 2021 1625 Dec 12, 2016
    лучше бы описал задание
     
    1. hokage Topic starter
      kageno,
      . Написать программу, которая во вводимом с клавиатуры тексте заменит первую букву на последнюю во всех словах текста и выведет результат на экран.
    2. kageno
      hokage,
      C
      #include <iostream>
      #include <string>

      int main()
      {
      int c = 0;
      std::string s;

      while(std::cin >> s) {
      std::cout << s[s.length() - 1] << s.substr(1, s.length() - 2) << s[0] << " ";
      }
      }
  3. Fender_inactive2697143
    В тексте могут встретиться знаки препинания? Как поступать с ними?
     
Top
Loading...