0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paiza.ioでc# その13

Posted at

概要

paiza.ioでc#、やってみた。
練習問題やってみた。

練習問題

AtCoderをhashsetを使って解け。

参考にしたページ

サンプルコード

abc097 c

using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static string InputPattern = "InputX";
    static List<string> GetInputList() {
        var WillReturn = new List<string>();
        if (InputPattern == "Input1") 
        {
            WillReturn.Add("aba");
            WillReturn.Add("4");
        }
        else if (InputPattern == "Input2") 
        {
            WillReturn.Add("atcoderandatcodeer");
            WillReturn.Add("5");
        }
        else if (InputPattern == "Input3") 
        {
            WillReturn.Add("z");
            WillReturn.Add("1");
        }
        else 
        {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) 
                WillReturn.Add(wkStr);
        }
        return WillReturn;
    }
    static void Main() {
        List<string> InputList = GetInputList();
        string S = InputList[0];
        int K = int.Parse(InputList[1]);
        var SubStrSet = new HashSet<string>();
        int UB = S.Length - 1;
        for (int I = 0; I <= UB; I++) 
        {
            for (int J = I; J <= UB; J++) 
            {
                int StrLen = J - I + 1;
                if (K < StrLen) 
                    break;
                SubStrSet.Add(S.Substring(I, StrLen));
            }
        }
        var Query = SubStrSet.OrderBy(pX => pX).ElementAt(K - 1);
        Console.WriteLine(Query);
    }
}





実行結果

b

成果物

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?