如何使用循环从非回文串中制作回文串中的回文串? [英] How do I make from non-palindrome string a palindrome string in C using loops?

查看:76
本文介绍了如何使用循环从非回文串中制作回文串中的回文串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如你输入:abcd和输出将是:abba。谢谢你们。



我的尝试:



i甚至不知道从哪里开始

解决方案

只需镜像字符串的前半部分(你知道,如果 s [i] == s,字符串就是回文结构[L-1-i])其中 L 是它的长度),你提供的样本建议你可以这样做。

你需要更仔细地阅读你的作业问题 - 它将解释你需要操作的规则,这些规则从一个简单的例子中就不清楚了。



当你完成后,首先在纸上试一试,并记下你必须完成的程序和流程。

翻译应该相对简单这需要一点点思考。



如果你遇到某个特定的部分,那么请务必询问,但我们不会全部为你。


首先你需要学习这个教程的基础,如 Learn C教程。安装Visual Studio以获得完整的开发工具。学习和玩耍。



您需要了解C的字符串和字符数组概念,并按照CPallini暗示操作数据。


For example you input: abcd and output will be: abba. thanks guys.

What I have tried:

i dont even know where to start

解决方案

Simply mirror the first half of the string (you know, a string is palindrome if s[i] == s[L-1-i]) where L is its length), the sample you provided suggest you are allowed to do it.


You need to read your homework question rather more closely - it will explain the rules you need to operate under, which are not clear just from one trivial example.

When you have done that try it on paper first, and make a note of the procedures and processes you had to go through to do it.
It should be relatively simple to translate that to code, with a little thought.

If you get stuck on a specific part, then by all means ask about that, but we will not do it all for you.


At first you need to learn the basic of the language from some tutorial like this Learn C tutorial. Install Visual Studio for a complete development tools. Learn and play around.

You need to understand the string and char array concept of C and manipulate your data as CPallini hinted.


这篇关于如何使用循环从非回文串中制作回文串中的回文串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆