本文主要是介绍C语言:字符串逆序输出, test ok,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
【问题描述】字符串逆序:设计函数功能是将一个字符串逆序,函数声明: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;
}
这篇关于C语言:字符串逆序输出, test ok的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!