C# CodinGame记录(4)--ASCII ART

总的来说还是很简单的。

先用Enum枚举出26个字母和"?"

然后根据输入的H和L,把每个字母的ASCII ART样式保存在一个string数组里

string[字母序号,H]

然后识别输入的字符串,每个进行判断,把每个字母的逐行放入string b里再加入\n换行,最后一起输出

using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
class Solution
{
        enum words {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,none};
    static void Main(string[] args)
    {

        int L = int.Parse(Console.ReadLine());
        int H = int.Parse(Console.ReadLine());
        string T = Console.ReadLine().ToUpper();
        int l =0;
        int w =0;
        string[,] word = new string[27,H];
        string b="";
        for (int i = 0; i < H; i++)
        {
            string ROW = Console.ReadLine();
            for (int j=0;j<27;j++){
                l=j*L;
                word[j,i]= ROW.Substring(l,L);
                
            }
        }
        for(int i =0;i<H;i++)
            {
            foreach(char a in T){
                string c =a.ToString();
                if(Enum.IsDefined(typeof(words),c)){
                    w =(int)(words)Enum.Parse(typeof(words),c);}
                else{w = 26;}
                b =b + word[w,i];
            }
            b= b+"\n";
        }       
            Console.WriteLine(b);
        

        // Write an answer using Console.WriteLine()
        // To debug: Console.Error.WriteLine("Debug messages...");

        
    }
}

 这里有个(int)(words)Enum.Parse(typeof(words),c)

其实是(int)(枚举名字)Enum.Parse(typeof(枚举名字),想要判断的变量)

就会输出一个“c”那个变量字符串的在枚举中的value

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值