69,381
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
int main()
{
char str[] = "this is a test";
int len = strlen(str)-1;
for(int i = 0; i<=len/2; i++)
{
char c = str[i];
str[i] = str[len-i];
str[len-i] = c;
}
cout<<str<<endl;
return 0;
}
全部逆序。// test2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string.h>
#include <stdio.h>
char string[] = "this is a test";
char seps[] = " ,\t\n";
char *token;
void main( void )
{
printf( "%s\r\n", string );
token = strtok( string, seps );
while( token != NULL )
{
//printf( " %s\n", token );
int l = strlen( token );
for( int i = l - 1; i >= 0; i-- )
{
printf( "%c", *( token + i ) );
}
printf( "%c", 0x20 );
token = strtok( NULL, seps );
}
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int i;
char* src = "this is a test";
char* ptr = src + strlen(src) - 1;
for (i = strlen(src); i > 0; i--)
{
printf("%c", *ptr--);
}
system("pause");
return 0;
}