代码文件:代码下载
#include <stdio.h>
#include <string.h>
void show(const char* const str);
char* Position_swap(char* const str);
int main(int argc, char* argv[])
{
char str[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
printf("Before the swap:");
show(str);
Position_swap(str);
printf("After the swap:");
show(str);
return 0;
}
/**********************************************
* 头文件:#include <stdio.h>
* 功 能:打印字符数组信息
* 函 数:void show(char * str)
* 参 数:str字符数组首地址
* 返回值:无
**********************************************/
void show(const char* const str)
{
int len = strlen(str);
int i = 0;
while (i <= len)
{
printf("%c",*(str + i++));
}
printf("\n");
}
/**********************************************
* 头文件:#include <string.h>
* 功 能:实现字符数组位子互换
* 函 数:char* Position_swap(char * str)
* 参 数:str字符数组首地址
* 返回值:str字符数组首地址
**********************************************/
char* Position_swap( char * const str)
{
int len = strlen(str);
int i = 0, j = len-1;
char ch = 0;
while (i <= j)
{
ch = *(str + i);
*(str + i) = *(str + j);
*(str + j) = ch;
i++;
j--;
}
return str;
}
本文地址:https://blog.csdn.net/weixin_42059464/article/details/107280473
如对本文有疑问, 点击进行留言回复!!
Codeforces C. A Cookie for You (模拟 / 分类 / 贪心) (Round #654 Div.2)
DialogFragment弹窗(带黑色透明背景和不带黑色透明背景)
网友评论