如何在C#中编写伪代码 [英] how to write pseudo code in C#

查看:890
本文介绍了如何在C#中编写伪代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何一个有伪代码的好东西?

你能编写一个简短的伪代码例程来反转字符串中的单词..

输入字符串如包含的项目一些错误进入错误很少包含项目?



这就是我所做的,



string a =The;

string b =project;

string c =contained;

string d =a;

string e =少;

string f =errors;



打印f,e,d,c,b,a



这好吗?

解决方案

< blockquote> Psuedocode和C#一起没有意义。

您可能正在寻找C#代码或算法。


我会这样做:< br $>


  string  input = Console.ReadLine(); 

string [] words = input.Split(' ');

for int i = words.length; i > 0 ; i - ) // 你可以做words.length-1或我在下一行做的事情
Console.Write(words [i-1] + ); // 删除1以匹配字符串数组偏移量非常重要!

控制台.WriteLine();





这是基本的,但不是一种非常优雅的方式。



顺便说一下,C#中没有打印:)


Any one good with pseudo code ?
Can you Write a short pseudo code routine to reverse the words in a string..
input string like "The project contained a few errors" into "errors few a contained project The"?

well this is what i have done,

string a = "The";
string b = "project";
string c = "contained";
string d = "a";
string e = "few";
string f ="errors";

print f, e, d, c, b, a

is this alright??

解决方案

Psuedocode and C# together don't make sense.
You are probably ooking for C# code or an algorithm.


I would do it like that:

string input = Console.ReadLine();

string[] words = input.Split(' ');

for(int i = words.length; i > 0; i--)// you could do words.length-1 or what I did on the next line
Console.Write(words[i-1] + " "); //important to remove 1 to match the string array offset!

Console.WriteLine();



Thats as basic as it can be, not a very elegant way to do it however.

By the way, there is no "print" in C# :)


这篇关于如何在C#中编写伪代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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