任何人都可以帮我这个代码 [英] Can anyone help me with this code

查看:83
本文介绍了任何人都可以帮我这个代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用C#编写了这个。


我只需将其转换为C.


da处理字符串时出现问题。在C语言中,字符串不会像在C#中那样表现出相同的行为。


如果说有人帮我做出来,那将是很好的帮助string

的工作方式与C#相同(对于此代码。)。

private void Caller()

{

Int32 a = 5;

partation(a,a,"");

}


private void partation(Int32 n,Int32 m,String s)

{

Int32 i;

if(n> 0)

{

for(i = Math.Min(n,m); i 0; i--)

partation(n - i,i, s + i.ToString()); //

问题来自这里.....


}

其他

{

Console.WriteLine(s); //这可以作为打印文件

}

}

我尝试使用sprintf,strcat,但没有用,它会打印一些垃圾

值(可能是我没有正确使用它们)。请帮助我..........

Insira

I have written this in C#.

I just need to convert it into C.

da problem comes when handling the String. In C the String doesn''t
behave the same way as in C#.

it would be great help if smeone cn help me out to make the string
work on the same way as in C# (for this code.).
private void Caller()
{
Int32 a = 5;
partation(a, a, "");
}

private void partation(Int32 n, Int32 m, String s)
{
Int32 i;
if(n>0)
{
for (i = Math.Min(n, m); i 0; i--)
partation(n - i, i, s + i.ToString()); // the
problem comes here.....

}
else
{
Console.WriteLine(s); //This can be put as a Printf
}
}
I tried using sprintf, strcat, but no use, it prints some garbage
values (may be im not using them correctly). pls pls help me..........
Insira

推荐答案

On 2008-09-17 07:43:41 +0200, in********@gmail.com 说:
On 2008-09-17 07:43:41 +0200, in********@gmail.com said:

我用C#编写了这个。


我只需将其转换为C. [...]
I have written this in C#.

I just need to convert it into C. [...]



对Int32使用int(或不太可能长),对String使用char *,使用str *

函数来处理字符串。顺便说一句,C没有课程:摆脱

私人。


既然你来自C#/ Java / ...,你可能需要一段时间来弄清楚

正确的转换。


你的挑战之一就是(现在就提到你好了

垃圾)了解记忆不是什么魔法:你必须分配(malloc和similia)并释放它。无论如何你一定不要害怕这个:b *其他语言*之前*使用像String这样的类

你需要使用new,我看不到真的malloc和

之间的差异(除了一些糖)。


并且不要害怕在这里发布愚蠢的代码,我甚至学到了很多东西

来自愚蠢的消息来源。


干杯!

-


Sensei * < Sensei'的电子邮件是在Mac-dot-com>


这是一个非常可悲的事情,现在有这么少无用的信息。

(奥斯卡王尔德)

Use int (or less likely long) for Int32, char* for String, and the str*
functions to handle strings. And by the way, C has no classes: get rid
of private.

Since you come from C#/Java/..., you may need some time to figure out
the "right conversion".

One of your challenges will be (and is right now since you mention
"garbage") learning that memory isn''t something "magic": you have to
allocate (malloc and similia) and free it. Anyway you must NOT be
afraid of this: in other languages *before* using a class like String
you need to use "new", and I see no real difference between malloc and
new (apart from some sugar).

And don''t be afraid to post idiotic code here, I learned a lot even
from stupid sources.

Cheers!
--

Sensei*<Sensei''s e-mail is at Mac-dot-com>

It is a very sad thing that nowadays there is so little useless information.
(Oscar Wilde)


** ******@gmail.com 说:

我用C#写的这个。


我只需要将其转换为C.
I have written this in C#.

I just need to convert it into C.



为什么不用英文描述你的问题

我们正试图解决这个问题,并向我们展示你在C中的最好成绩解决方案?


一旦我们知道你要做什么(用英语)以及你如何尝试

这样做(在C中) ),我们有机会帮助你实现你的目标。


-

理查德希思菲尔德< ; http://www.cpax.org.uk>

电子邮件:-http:// www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日

Instead of showing C# code, why not describe, in English, the problem you
are trying to solve, and show us your best shot at a C solution?

Once we know what you''re trying to do (in English) and how you''re trying to
do it (in C), we have a fighting chance of being able to help you achieve
your objective.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


2008年9月17日星期三07:01:46 +0000,Richard Heathfield发布:
On Wed, 17 Sep 2008 07:01:46 +0000, Richard Heathfield posted:
in********@gmail.com 说:

>我用C#编写了这个。

我只需将其转换为C.
>I have written this in C#.

I just need to convert it into C.



显示C#代码,为什么不用英语描述你想要解决的问题,并告诉我们你在C解决方案中的最佳表现?


一旦我们知道你想要做什么(用英语)以及你如何尝试(b)b
,我们就有机会帮助你实现

你的目标。


Instead of showing C# code, why not describe, in English, the problem you
are trying to solve, and show us your best shot at a C solution?

Once we know what you''re trying to do (in English) and how you''re trying to
do it (in C), we have a fighting chance of being able to help you achieve
your objective.



当你看到时,我不认为英语有多大帮助:


private void partation(Int32 n,Int32 m ,String s)


我认为下一个突变将是C flat。不过我经常是错的。

-

禁酒主义者就是那种无法忍受喝酒的男人,即使是

,如果他喝酒。

HL Mencken

I don''t think english helps much when you see:

private void partation(Int32 n, Int32 m, String s)

I think the next mutation will be C flat. I''m frequently wrong, though.
--
A prohibitionist is the sort of man one couldn''t care to drink with, even
if he drank.
H. L. Mencken


这篇关于任何人都可以帮我这个代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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