用C语言剪切和粘贴 [英] Cut and paste in C language

查看:363
本文介绍了用C语言剪切和粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我必须用c语言编写一个没有字符串函数的程序,它可以得到一个字符串和3个数字。例如,字符串是abcdefghi,你输入第一个数字3,第二个数字是你的目的地5然后是第三个数字7,程序应该给你abfcdeghi,它就像剪切和粘贴一样!



我尝试了什么:



我还没有尝试过任何东西!我甚至不知道如何开始:(

hi I have to write a program in c language without string functions that gets a string and 3 numbers . for example the string is "abcdefghi" and you enter the 1st number 3 , the 2nd number that's your destination 5 and then the 3rd number 7 , the program should give you "abfcdeghi" ,its like cut and paste !

What I have tried:

well I haven't tried anything yet ! i don't even know how to start :(

推荐答案

考虑为实现这一目标需要采取的步骤:

你如何阅读角色以及在哪里保存它们?

你如何阅读这些数字以及你在哪里保存它们?

你如何从中找到角色给定的数字?

如何将字符从一个位置移动到另一个位置而不破坏现有位置(例如复制,移动......)?

如何打印结果?



在纸上写下来,看看每一步都会发生什么。
Think about the steps you need to take in order to achieve this:
How do you read the characters and where do you save them?
How do you read the numbers and where do you save them?
How do you find the characters from the given numbers?
How do you move characters from one position to another, without destroying the existing ones (e.g. copy, move ...)?
How do you print the results?

Write things out on paper and see what happens at each step.


输入是:abcdefghi

结果是:abfcdeghi

你有3个数字3,5和7.



第一件事:你需要了解这些数字是什么,因为要在一个字符串中移动1个字母,你只需要2个数字:开始和结束位置。



之后,你需要弄清楚如何得到想要的res ult。

作为程序员,你的工作是创建算法,我们不会为你做,这是你的功课。



我们不做你的家庭作业。
Input is : "abcdefghi"
result is: "abfcdeghi"
and you have 3 numbers 3, 5 and 7.

First thing: you need to understand what are those numbers, because to move 1 letter in a string, you need only 2 numbers: starting and ending positions.

After that, you need to figure out how go to get wanted result.
As programmer, your job is to create algorithms, we don't do it for you, it is your homework.

We do not do your HomeWork.


这篇关于用C语言剪切和粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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