#include <stdio.h> #include <iostream> #include <string.h> #include <string> #include <algorithm> #include <iomanip> #include<vector> #include<math.h> using namespace std; int main() { string s; while (gets(s)!=NULL){ int k = 0; for (int i = 0; i < s.length(); i++) { if (isalpha(s[i])) { k++; } else { if (k != 0) { for (int j = i - 1; j >= i - k; j--) { cout << s[j]; } k = 0; cout << s[i]; } else cout << s[i]; } } for (int j = s.length() - 1; j >= s.length() - k; j--) { cout << s[j]; } cout << endl; } } /* Main.cc: In function 'int main()': Main.cc:13:15: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations] while (gets(s)!=NULL){ ^ In file included from Main.cc:1: /usr/include/stdio.h:583:14: note: declared here extern char *gets (char *__s) __wur __attribute_deprecated__; ^~~~ Main.cc:13:15: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations] while (gets(s)!=NULL){ ^ In file included from Main.cc:1: /usr/include/stdio.h:583:14: note: declared here extern char *gets (char *__s) __wur __attribute_deprecated__; ^~~~ Main.cc:13:14: error: cannot convert 'std::__cxx11::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*' while (gets(s)!=NULL){ ^ In file included from Main.cc:1: /usr/include/stdio.h:583:26: note: initializing argument 1 of 'char* gets(char*)' extern char *gets (char *__s) __wur __attribute_deprecated__; ~~~~~~^~~ Main.cc:15:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare] for (int i = 0; i < s.length(); i++) { ~~^~~~~~~~~~~~ Main.cc:32:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare] for (int j = s.length() - 1; j >= s.length() - k; j--) { ~~^~~~~~~~~~~~~~~~~ */ |
Double click to view unformatted code.