当前位置:网站首页>指针 --按字符串相反次序输出其中的所有字符
指针 --按字符串相反次序输出其中的所有字符
2022-07-06 09:24:00 【|光|】
要求
编写程序,输入一个字符串,按相反次序输出其中的所有字符。(用指针实现)
代码
/* * 该函数实现对字符串a的反序操作,如原始字符串为string,反序后为gnirts, * 请反序后的字符串仍然存放在a所指向的内容中 */
void reverse(char *a)
{
int n = strlen(a);
int b[n],c = 0;
for(int i = n-1;i>=0;i--)
{
b[c] = a[i];
c++;
}
for(int i = 0;i<n;i++)
{
a[i] = b[i];
}
}
main函数
int main()
{
char a[200];
gets(a);
reverse(a);
puts(a);
return 0;
}
测试
测试输入
I am a student
输出
tneduts a ma I
边栏推荐
- 网络层—简单的arp断网
- Tencent map circle
- 数据库多表链接的查询方式
- 浙大版《C语言程序设计实验与习题指导(第3版)》题目集
- SystemVerilog discusses loop loop structure and built-in loop variable I
- MSF generate payload Encyclopedia
- 内网渗透之内网信息收集(二)
- How to test whether an object is a proxy- How to test if an object is a Proxy?
- ES全文索引
- Wei Shen of Peking University revealed the current situation: his class is not very good, and there are only 5 or 6 middle-term students left after leaving class
猜你喜欢
Windows platform mongodb database installation
Binary search tree concept
Realize applet payment function with applet cloud development (including source code)
Intranet information collection of Intranet penetration (2)
Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
关于交换a和b的值的四种方法
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
Web vulnerability - File Inclusion Vulnerability of file operation
随机推荐
2022华中杯数学建模思路
flask实现强制登陆
链队实现(C语言)
内网渗透之内网信息收集(一)
图书管理系统
. Net6: develop modern 3D industrial software based on WPF (2)
循环队列(C语言)
Harmonyos JS demo application development
How to turn wechat applet into uniapp
Wei Shen of Peking University revealed the current situation: his class is not very good, and there are only 5 or 6 middle-term students left after leaving class
1.支付系统
内网渗透之内网信息收集(五)
Sword finger offer 23 - print binary tree from top to bottom
Hackmyvm target series (4) -vulny
《统计学》第八版贾俊平第四章总结及课后习题答案
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
7-6 local minimum of matrix (PTA program design)
Ucos-iii learning records (11) - task management
Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class