如何将下面的C语言转化成C#

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何将下面的C语言转化成C#相关的知识,希望对你有一定的参考价值。

#include <stdio.h>
int main()

int a=500,n,m=1,sum=0,cnt=0;
for(a=800;a>=500;a--) //为了保证得到的素数是从大到小的,a取值也从大到小
for(n=2;n<a;n++)
if(a%n==0)break;
if(a==n)
sum=m*a+sum; //找到一个素数,才累加,m才换正负
cnt++;
m=-m;


printf("%d %d",cnt,sum);

完整的直译为java方法是这样的,但是这样写dataLen的值必须小于等于数组长度,不然会出现下标越界的异常

public int accumulativeVerification(int[] data, int dataLen) int sum = 0; for (int i = 0; i < dataLen; i++) sum += data[i]; return sum;

如果是意译(计算int数组的所有数之和),那么java可以这样写

public int accumulativeVerification(int[] data) int sum = 0; for (int i = 0; i < data.length; i++) sum += data[i]; return sum;
参考技术A 新建一个控制台项目。把main里代码复制进去里面的Main。
printf("%d %d",cnt,sum);
改成
Console.WriteLine("0,'1'",cnt,sum);

麻烦英语帝将下面的文字翻译成英语,语言力求简洁、优美。谢谢

当被人问及最喜欢的电影时,我可以毫无迟疑地告诉他,无间道。这是一部极具香港色彩的电影,正如主题曲:谁了解生存往往比命运还残酷,只是没有人愿意认输。
这是一个有关于生存的故事,而似乎“生存”这个主题,在这样一个夹缝似的时代中却又如此的尖锐。

快到终点才能知道 ,又再回到起点从头上路。
死亡,已不再是单纯意义上解脱或是逃避的演绎,而是一声享受中的绝版叹息,他真的没有选择,因为有些路终究要一个去走。
永远忘不了,这种空前的无助,那张抓狂扭曲的脸和那双恐惧的极欲呼喊的眼睛,完成了一场对生命情感的完美诠释!也许死亡者本身,永远都不会流露出过多的痛苦,却让屏幕前的人们
为之长久的哭泣。这便是男人的无奈,沉重的让人无力承受,更不忍承受!
无间有三,时无间,空无间,受者无间。
解脱,是他们最终的夙愿。然而,解脱的结果,地狱,或者,天堂。
天空是博大广阔,空灵明净的,只有在这蔚蓝的苍宇下,被压抑的灵魂,才能更显他的光明磊落。
两个身份都本不该属于自己的人,他们几乎生活在一个类似无间地狱的环境里,做梦都怕别人拆穿自己的身份。
世分正邪,人有强弱,一切争斗都是源于人与人的冲突...于是,每个人都集合了矛盾,每个人都有敌人,每个人都在求生,每个人也都能杀生...归根到底,大家迟早一样.
但如果谁能及时而准确的控制别人的生命,那么,这种死亡的提前,就是整死了你,埋葬了一个秘密......
谁都有秘密,谁也都没有秘密,强大的是思想,脆弱的是身躯...无论你是老大还是混混,是警司还是卧底,无论你聪明的装成黑帮,还是狡猾的扮成警察,任何人都敌不过一颗子弹...
有一种杀戮人人平等,管你是谁,死,都是一颗子弹...你不能祈祷我打不中你,只能祈祷你先打中我...因为,你的幸运,就是我的不幸...无间道里,谁都会开枪....子弹埋葬一切秘密....
请不要用翻译器的回答。

[绝对原创,非抄袭!!非机器翻译!!!!!!!求采纳]

当被人问及最喜欢的电影时,我可以毫无迟疑地告诉他,无间道。
When asked about what movie I like best ,there is no doubt ,I will tell him Infernal Affairs.

这是一部极具香港色彩的电影,正如主题曲:谁了解生存往往比命运还残酷,只是没有人愿意认输。
This is a kind of move filled with Hong Kong legend .As is the same with the theme song :Who has a good knowledge of living is often more cruel than destiny ,and just nobody gives up.

这是一个有关于生存的故事,而似乎“生存”这个主题,在这样一个夹缝似的时代中却又如此的尖锐。This is a story about living ,but it seems that the theme of the “living” is so aculeated in this period of epoch which is too narrow.

快到终点才能知道 ,又再回到起点从头上路。
When one is nearly reaching to his end point ,he realizes that he comes back to jumping-off point again and then goes on his way.

死亡,已不再是单纯意义上解脱或是逃避的演绎,而是一声享受中的绝版叹息,他真的没有选择,因为有些路终究要一个去走。Death is not the single meaning of going away or avoiding something any more ,but a sigh of voice in enjoyment .Really ,he has no choice ,for there are always some ways that a single person has to go alone.

永远忘不了,这种空前的无助,那张抓狂扭曲的脸和那双恐惧的极欲呼喊的眼睛,完成了一场对生命情感的完美诠释!
It will never be forgotten that helplessness all the time ,crazy face and the eyes filled with screaming have finished showing the emotion of this life.

也许死亡者本身,永远都不会流露出过多的痛苦,却让屏幕前的人们为之长久的哭泣。Maybe the person who face death will never show too much pain .However ,people under the screen cry with sadness.

是男人的无奈,沉重的让人无力承受,更不忍承受!It is man’s helplessness ,and it is too heavy for them to burden ,let alone standing it.

无间有三,时无间,空无间,受者无间。The Infernal Affairs consists of three key principles :no time ,no space ,no pains.

解脱,是他们最终的夙愿。Going far away is their last wish.

然而,解脱的结果,地狱,或者,天堂。
However ,after they getting away from that ,they reach hell or paradise.

天空是博大广阔,空灵明净的,只有在这蔚蓝的苍宇下,被压抑的灵魂,才能更显他的光明磊落。
The sky is large ,bright and clean .Only under this blue sky can the soul under too much pressure show its innocence.

两个身份都本不该属于自己的人,他们几乎生活在一个类似无间地狱的环境里,做梦都怕别人拆穿自己的身份。
They who have two different identities which do not belong to them almost lives in a circumstance likes a kind of hell which has no end.

世分正邪,人有强弱,一切争斗都是源于人与人的冲突...
There is something right or wrong ,and people strong or weak .And all conflict do come from people themselves.
于是,每个人都集合了矛盾,每个人都有敌人,每个人都在求生,每个人也都能杀生...So every person has conflict ,and enemy ,and the desire to live up ,and every person can also kill others.

归根到底,大家迟早一样.In a word ,all people are about the same.

但如果谁能及时而准确的控制别人的生命,那么,这种死亡的提前,就是整死了你,埋葬了一个秘密......However ,If someone can control others’ lives in time ,that leads to a secret which means killing you equals to the death of the pre-coming.

谁都有秘密,谁也都没有秘密,强大的是思想,脆弱的是身躯...Whoever has secret or they do not has .What is strong is our mind ,and what is weak is our body.

无论你是老大还是混混,是警司还是卧底,无论你聪明的装成黑帮,还是狡猾的扮成警察,任何人都敌不过一颗子弹...No matter what you are ,the big or the small ,and the police or the spy ,and no matter how smart you are if you dress up as a gangster ,or a policeman ,no one can avoid a bullet.

有一种杀戮人人平等,管你是谁,死,都是一颗子弹...There is a kind of killing which equals to everyone .No matter who you are ,you will be dead if you were caught by a bullet.

你不能祈祷我打不中你,只能祈祷你先打中我...You can not pray that I will not shoot you ,instead you can only pray that you will shoot me right first.

因为,你的幸运,就是我的不幸...Because what is your luck means I am unlucky.无间道里,谁都会开枪....In the dark world ,whoever will pull his trigger.

子弹埋葬一切秘密....And all the secret will be buried by one bullet.追问

恩人!请再帮我翻译一下最后的两句。
他们默默承受着只属于卧底的煎熬与无奈.看到这样无助的眼神,我忽然间觉得,那就是我们自己。每一个人,都能在无间道里找到自己的影子。

只有在心爱的女人的怀抱,这样宁静的夜才能出现在他的梦里.

一个只能在巷道里对着死去的警官举起自己伤痕累累的手臂,另一个虽然能当着全港警察的面从容地扬起他有力的臂弯.

他西装革履,却见不得光。

参考技术A When asked in the most loved movies, I can not hesitate to tell him, infernal affairs. This is a great Hongkong color film, as the theme song: who understand life more often than fate is cruel, but no one is willing to admit defeat.
It is a story of survival, and seems to" survive" this theme, in such a crack like age and yet so sharp.
The end is to know, and then to start over.
Death, is no longer the simple sense of release or escape of interpretation, but a sound to enjoy in the out-of-print sigh, he really had no choice, because some road will eventually be a go go.
Never forget, this unprecedented helpless, the crazy twisted face and the fear to cry eyes, completed a perfect interpretation of life and emotion! Perhaps even death itself, never showing too much pain, but let the screen in front of the people
For long. This is the man is helpless, unable to bear the heavy people, more cannot bear!
In three, when together, empty without, recipients have.
Free, was their final long-cherished wish. However, the results from hell, or heaven,.
The sky is broad and wide, ethereal clean, only in the blue blue woo, suppressed the soul, to his more open and aboveboard.
Two identity should not belong to themselves, they almost living in a similar infernal environment, dreams are afraid that others saw their own identity.
The world is divided between good and evil, people have strong or weak, all the fights are derived from human conflict... So, everyone is a collection of contradiction, everyone is the enemy, everyone to live in, and everyone can kill you ... In the final analysis, sooner or later.
But if anyone can timely and accurately control the lives of others, so, this death in advance, is killed you, buried a secret ... ...
Everybody has secrets, who also have no secrets, powerful ideas, fragile body ... Whether you are old or gangster, SP is still undercover, whether you clever loaded into the gang, or sly disguised as police, anyone enemy but a bullet ...
There is a kind of killing everyone is equal, no matter who you are, death, is a bullet ... You can't pray I don't hit you, can only pray for you to hit me... Because, lucky for you, is my misfortune ... Infernal Affairs, who can shoot bullets ... Bury all the secrets ....
参考技术B When people asked about favorite movie, I have no hesitate to tell him, no top-grossing. This is a most Hong Kong colour film, as the theme song: who understand survival than cruel fate is often, but no one is willing to admit defeat. This is a story about survival, and it seems "existence" the theme, in such a crack in the age of like but so sharp. Near the finish to know, and go back to the starting point from the road. Death, is no longer simple sense of relief or escape to deduce, but a sound the out of print enjoy sigh, he really have no choice, because some road will ultimately a to go. Never forget, this unprecedented helpless, that piece of mad twisted face and the fear of the desire of cries of eyes, completed a life emotion ideal explanation! Perhaps death itself, will never reveal too much pain, but makes the screen people For the cry for a long time. This is man's helpless, heavy 参考技术C 楼下莫抄袭 When people asked about favorite movie, I have no hesitate to tell him, no top-grossing. This is a most Hong Kong colour film, as the theme song: who understand survival than cruel fate is often, but no one is willing to admit defeat. This is a story about survival, and it seems "existence" the theme, in such a crack in the age of like but so sharp. Near the finish to know, and go back to the starting point from the road. Death, is no longer simple sense of relief or escape to deduce, but a sound the out of print enjoy sigh, he really have no choice, because some road will ultimately a to go. Never forget, this unprecedented helpless, that piece of mad twisted face and the fear of the desire of cries of eyes, completed a life emotion ideal explanation! Perhaps death itself, will never reveal too much pain, but makes the screen people For the cry for a long time. This is man's helpless, heavy

以上是关于如何将下面的C语言转化成C#的主要内容,如果未能解决你的问题,请参考以下文章

c语言中怎么把不同类型转化成同一类型?

Java语言中,如何将String转化成Int数组

c语言中如何将字符串转化成整数型并输出?

c语言中如何将字符串转化成整数型并输出?

c语言中如何将字符串转化成整数型并输出?

c#语言中怎么把int 型的数字转化为string 型输出