char e string em linguagem D

dark777 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 13 20:19:55 PDT 2017


On Thursday, 13 July 2017 at 22:30:29 UTC, crimaniak wrote:
> On Thursday, 13 July 2017 at 21:49:40 UTC, dark777 wrote:
>> Pessoal eu fiz o seguinte programa em C++.
>>
>> https://pastebin.com/CvVv6Spn
>>
>> porem tentei fazer o equivalente em D mas nao entendi muito 
>> bem...
>>
>> https://pastebin.com/2xw9geRR
>>
>> alguem poderia me ajudar?
>
> Se acepta utilizar intervalos en lugar de punteros desnudos. 
> (Hola, soy traductor de google)
>
> import std.stdio, std.string;
>
> //https://www.vivaolinux.com.br/script/GNU-que-bacana
>
> class GnuQueBacana
> {
>    this(){}
>
>   char[] stalman()
>   {
>       return cast(char[])`
>                   ((__-^^-,-^^-__))
>                    *---*******---*
>                     *--|o   o|--*
>                        \     /
>                         ): :(
>                         (o_o)
>                           -
>                  https://www.gnu.org
>
> `;
>   }
>
>   char[] torvald()
>   {
>       return cast(char[])`
>                         #####
>                        #######
>                        ##O#O##
>                        #######
>                        ##\#/##
>                     #lllllllllll##
>                    #lllllllllllll##
>                    #lllllllllllll###
>                    ##llllllllllll###
>                   OOO#llllllllll#OOO
>                  OOOOOO#llllll#OOOOOO
>                 OOOOOOO#llllll#OOOOOOO
>                  OOOOOOO######OOOOOOO
>                 https://www.kernel.org
>
> `;
>   }
>
>   string stallman()
>   {
>       return `
>                   ((__-^^-,-^^-__))
>                    *---*******---*
>                     *--|o   o|--*
>                        \     /
>                         ): :(
>                         (o_o)
>                           -
>                  https://www.gnu.org
>
> `;
>   }
>
>   string torvalds()
>   {
>       return `
>                         #####
>                        #######
>                        ##O#O##
>                        #######
>                        ##\#/##
>                     #lllllllllll##
>                    #lllllllllllll##
>                    #lllllllllllll###
>                    ##llllllllllll###
>                   OOO#llllllllll#OOO
>                  OOOOOO#llllll#OOOOOO
>                 OOOOOOO#llllll#OOOOOOO
>                  OOOOOOO######OOOOOOO
>                 https://www.kernel.org
>
> `;
>   }
>
> };
>
> void main()
> {
>   GnuQueBacana gnu = new GnuQueBacana();
>
>   writeln(gnu.stalman(), gnu.torvald(), gnu.stallman(), 
> gnu.torvalds());
> }

muito massa nao achei que era tao simples assim..


More information about the Digitalmars-d-learn mailing list