当前位置:网站首页>指针 --按字符串相反次序输出其中的所有字符
指针 --按字符串相反次序输出其中的所有字符
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
边栏推荐
- [issue 18] share a Netease go experience
- Sentinel overall workflow
- 网络层—简单的arp断网
- Bing Dwen Dwen official NFT blind box will be sold for about 626 yuan each; JD home programmer was sentenced for deleting the library and running away; Laravel 9 officially released | Sifu weekly
- “人生若只如初见”——RISC-V
- Fire! One day transferred to go engineer, not fire handstand sing Conquest (in serial)
- 使用 flask_whooshalchemyplus jieba实现flask的全局搜索
- Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
- 《统计学》第八版贾俊平第四章总结及课后习题答案
- Based on authorized access, cross host, and permission allocation under sqlserver
猜你喜欢

《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案

sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现

网络基础之路由详解

《英特尔 oneAPI—打开异构新纪元》

Uibutton status exploration and customization

"Gold, silver and four" job hopping needs to be cautious. Can an article solve the interview?

Hackmyvm Target Series (3) - vues

记一次api接口SQL注入实战

Résumé des points de connaissance et des réponses aux exercices après la classe du chapitre 7 de Jia junping dans la huitième édition des statistiques

7-7 7003 combination lock (PTA program design)
随机推荐
Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
7-14 error ticket (PTA program design)
Realize applet payment function with applet cloud development (including source code)
Always of SystemVerilog usage_ comb 、always_ iff
Middleware vulnerability recurrence Apache
线程的实现方式总结
内网渗透之内网信息收集(四)
XSS之冷门事件
搭建域环境(win)
HackMyvm靶機系列(3)-visions
"Gold, silver and four" job hopping needs to be cautious. Can an article solve the interview?
Hackmyvm target series (1) -webmaster
How to test whether an object is a proxy- How to test if an object is a Proxy?
. Net6: develop modern 3D industrial software based on WPF (2)
XSS (cross site scripting attack) for security interview
Lintcode logo queries the two nearest saplings
DVWA (5th week)
New version of postman flows [introductory teaching chapter 01 send request]
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
Network technology related topics