OJ Problem 3454 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;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.IO;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num=int.Parse(Console.ReadLine());
            string str=Console.ReadLine();
            string[] strs = str.Split("".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); int[] arr = new int[200];
            int[] nums = new int[100];
            int len = strs.Length;
            for(int i=0;i<len;i++)
            {
                nums[i] = int.Parse(strs[i]);
            }
            for(int i=0;i<len;i++)
            {
                for(int j=0;j<len;j++)
                {
                    if (j != len - 1 - i)
                    {
                        Console.Write("{0} ", nums[j]);
                    }
                }
                Console.WriteLine();
            }
        }
    }
} 

猜你喜欢

转载自blog.csdn.net/wangws_sb/article/details/105111289
今日推荐