zoukankan      html  css  js  c++  java
  • 问题 B: C#组成考题字符串

    题目描述

    假定已经获取题库中的试题号,并存放在数组arrayKT中。例如, int [] arrayKT={10,13,18,19,20,22,30,31}。定义一个静态成员方法,该方法实现从上述数组中随机抽出n(n=arrayKT.Length-1)道考题,并组成一个考题字符串。比如,随机从arrayKT中抽取n题组成考题字符串:“10,13,18,20,22,30,31”。要求,组成考题字符串中考题不重复,输出所有可能的字符串。 

    输入

    题目的个数
    数组中的考题号;

    输出

    所有可能的考题字符串;

    样例输入

    5
    1 2 3 4 5

    样例输出

    1 2 3 4
    1 2 3 5
    1 2 4 5
    1 3 4 5
    2 3 4 5
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
     
    namespace 组成考题字符串
    {
        class Program
        {
            static void Main(string[] args)
            {
                int n = Convert.ToInt32(Console.ReadLine());
                string s = Console.ReadLine();
                string[] s1 = s.Split(' ');
                int[] a = Array.ConvertAll(s1, int.Parse);
                 
                 
                for (int i = n - 1; i >= 0; --i)
                {
                    for (int j = 0; j < n; ++j)
                    {
                        if(i != j)
                        {
                            Console.Write("{0} ", a[j]);
                        }
     
                    }
                    Console.WriteLine();
                }
                Console.ReadKey();
            }
        }
    }
    

      

  • 相关阅读:
    poi隐藏列
    凯西太太的果园
    java中不可变对象深入理解
    excel添加空白行的快捷键
    如何在多个页面中,引入一个公共组件
    对后端返回的数据进行适配
    我与时间管理的故事
    在前端团队的那些日子(初见)
    我是这样做时间管理的(下)
    我是这样做时间管理的(上)
  • 原文地址:https://www.cnblogs.com/mjn1/p/12576445.html
Copyright © 2011-2022 走看看