-
#include ""
#include
#include
#include
#include
using namespace std;
int main()
unsigned int n;
cout <<"Please enter the number of strings" >n;
vectora(n);
system("cls");
cout <<"Start typing" cout <<"Please enter section" >a[i];
int length = a[i].size();
string temp=a[i];
for (int j = 0; j <= length / 2; j++)
char c = temp[j];
temp[j] = temp[length - j - 1];
temp[length - j - 1] = c;
a[i] = temp;
sort(,cout <<"The output string is:" int length = a[i].size();
string temp;
temp = a[i];
for (int j = 0; j <= length / 2; j++)
char c = temp[j];
temp[j] = temp[length - j - 1];
temp[length - j - 1] = c;
a[i] = temp;
cout <
I don't know what kind of problem you're talking about.
Anyway, I'm okay with this one. You can give it a try.
It seems to be too professional......)
-
To put it bluntly, pointers are not declared and can be used. Your pointers are all wild pointers if they are not initialized. You can't store the string you entered.
There is no value at the beginning, and it cannot be sorted; char*p[5];for(inti=0;i>p[i];} used up for(inti=0; i<5;i++)
-
There is a utility class collections in the collections, which can be called directly to sort the collection inversely** for example, there is a collection: listlist=invert the sorting method:;
-
It's easy, first an array takes in the input string, and then defines an array of the same length as the input.
Recirculation can be reversed, **I won't write, the method is better than **heavy.**
-
For a string of length n, if n is an even number, swap n 2 times, n is an odd number, for example, n = 5, you need to swap 2 times, and in summary, the string reversal needs to swap n 2 times.
Originally, you could solve it by swapping n 2 times, but now you swap n times and n 2 more times, and let you exchange it back, so it is equivalent to no exchange.
-
Apply C++ string object implementation. For the sake of generality, spaces are allowed in the object; Custom inverse function parameters should use reference types to permanently change the operation on the argument object. Examples are as follows:
#include ""//if the vc++,with this line.
#include
#include
using namespace std;
void mystrrev(string &str){ Reference the parameters to change the arguments. }
for(int j=,i=0;i
Example of a result:
-
Non-recursive. #include
char *reverse_string(char *str);
sprintf(ss, "abcdefg");
char *ss_rev = reverse_string(ss);
printf("ss_rev =%s", ss_rev);
return 0;
Recursive. #include
#include
#include
char* reverse_string(char * string)
if (null == string) ;
sprintf(ss, "abcdefg");
char *ss_rev = (char *)reverse_string(ss);
printf("ss_rev =%s", ss_rev);
return 0;Thank you!
-
It can be translated by the following function method
#include
#include
using namespace std;
void main()
Outputs the swapped string.
-
Actually, it's very simple, upstairs mainly uses the library functions in stl, and we can implement it ourselves:
#include
#include
using namespace std;
void main()
Outputs the swapped string.
cout<
-
j=strlen(str)
It should be changed to j=strlen(str)-1
Because strlen(str) is the length of the string, and the string subscript starts at 0, strlen(str)-1 is the last character.
strlen(str) is the end of the string'\0'
You copied the end character to the first position, causing the string to end at the beginning.
-
j=strlen(str) is not true, in this case str[j] is the closing character, j=strlen(str)-1 can correct the error that the book is empty, but the loop should be half of strlen(str). This will output the strings in their original order.
For example: int mid=strlen(str) 2;
for(i=0,j=strlen(str)-1;i
-
for(i=0,j=strlen(str);i should be for(i=0,j=strlen(str) -1; For example, if you type abcde, your j should point to e, which is the 4th position (from 0), not the 5th.
There is no difference between a string and an array of characters. >>>More
Just take a look at this one**.
Hope it helps. >>>More
Use the ITOA function.
Prototype: extern char *itoa(int i); >>>More
Do it by your train of thought.
Method 1. string strnumber="200m"; >>>More
The difference between the length of an array and the length of a string is that the ending flag is different and the characteristics are different. >>>More