作业1

55 阅读1分钟

`using System;

namespace 特定单词 { class Program { //basketball //b2 a2 s1 k1 e1 t1 l2 static void Main(string[] args) { int[] count = new int[7]; Console.WriteLine("输入一串英文字符"); string text = Console.ReadLine(); for (int i = 0; i < text.Length; i++) { if (text[i] == 'b') { count[0]++; } if (text[i] == 'a') { count[1]++; } if (text[i] == 's') { count[2]++; } if (text[i] == 'k') { count[3]++; } if (text[i] == 'e') { count[4]++; } if (text[i] == 't') { count[5]++; } if (text[i] == 'l') { count[6]++; }

        }
        count[0] = count[0] / 2;
        count[1] = count[1] / 2;
        count[6] = count[6] / 2;
        int min = count[0];
        for (int i = 1; i <= 6; i++)
        {
            if (min <= count[i])
            {
                min = min;
            }else
            {
                min = count[i];
            }
        }
        Console.WriteLine("可以拼出{0}个basketball", min);
    }
}