字符串数组反转
Here you will get C++ program to reverse all the strings stored in an array.
在这里,您将获得C ++程序来反转存储在数组中的所有字符串。
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
char a[3][50];
int i,j,k,len;
cout<<"Enter 3 strings:\n";
for(i=0;i<3;i++)
{
gets(a[i]);
}
cout<<"\nThe list of orignal strings:\n" ;
for(i=0;i<3;i++)
{
cout<<a[i]<<"\n";
}
cout<<"\nThe list of changed strings:\n";
for(i=0;i<3;i++)
{
len=strlen(a[i]);
for(j=0,k=len-1;k>=0;j++,k--)
{
cout<<a[i][k];
}
cout<<"\n";
}
return 0;
}
Output
输出量
Enter 3 strings: how are you
进入3个字符串: 你 怎么样
The list of orignal strings: how are you
一部开拓创新的字符串列表: 你 怎么样
The list of changed strings: woh era uoy
更改的字符串列表: Woh 时代 uoy
翻译自: https://www.thecrazyprogrammer.com/2011/03/c-program-to-reverse-all-strings-stored.html
字符串数组反转