【问题描述】字符串逆序:设计函数功能是将一个字符串逆序,函数声明:void stringNx(char a[ ]),使用这个函数完成将输入的字符串逆序输出。
【输入形式】要求输入一个字符串
【输出形式】逆序后输出
【样例输入】abcd
【样例输出】dcba
【样例说明】【评分标准】2个测试数据
#include<stdio.h>
#include<string.h>
#include<iostream>
void stringNx(char a[])
{
int i = strlen(a) - 1;
int t = 0;
for (t = 0; t < i; i--, t++)
{
char temp;
temp = a[t];
a[t] = a[i];
a[i] = temp;
}
}
int main()
{
char a[10] = "abcdefg";
stringNx(a);
printf("%s", a);
system("pause");
return 0;
}