#include <stdio.h> #include <iostream> #include <string.h> #include <string> #include <algorithm> #include <iomanip> #include<vector> #include<math.h> using namespace std; int main() { char s[1000]; while (gets_s(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:9: error: 'gets_s' was not declared in this scope while (gets_s(s)!=NULL){ ^~~~~~ Main.cc:13:9: note: suggested alternative: 'gets' while (gets_s(s)!=NULL){ ^~~~~~ gets Main.cc:15:25: error: request for member 'length' in 's', which is of non-class type 'char [1000]' for (int i = 0; i < s.length(); i++) { ^~~~~~ Main.cc:32:18: error: request for member 'length' in 's', which is of non-class type 'char [1000]' for (int j = s.length() - 1; j >= s.length() - k; j--) { ^~~~~~ Main.cc:32:39: error: request for member 'length' in 's', which is of non-class type 'char [1000]' for (int j = s.length() - 1; j >= s.length() - k; j--) { ^~~~~~ */ |
Double click to view unformatted code.