zoukankan
html css js c++ java
(C#)ACM考试题的第二题
这个有点难啊。暂时这么做了做,不符合第二条要求。BBC的话。会有重复的。
BBC
BCB
BCB
CBB
虽然筛选不重复的肯定可以实现,不过这肯定不是题目原意。有时间需要重新做一下
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.IO;
namespace
ACM2
{
class
Program
{
static
void
Main(
string
[] args)
{
FileStream fs
=
new
FileStream(args[
0
], FileMode.Open, FileAccess.Read);
StreamReader sr
=
new
StreamReader(fs);
string
s
=
sr.ReadLine();
int
n
=
int
.Parse(s);
for
(
int
i
=
0
; i
<
n; i
++
)
{
s
=
sr.ReadLine();
Console.WriteLine(
"
Case
"
+
(i
+
1
));
Deal(s);
}
}
static
string
Sort(
string
str)
{
char
[] cs
=
str.ToCharArray();
char
temp;
for
(
int
i
=
0
;i
<
cs.Length;i
++
)
for
(
int
j
=
i;j
<
cs.Length;j
++
)
if
(cs[i]
>
cs[j])
{
temp
=
cs[i];
cs[i]
=
cs[j];
cs[j]
=
temp;
}
return
new
string
(cs);
}
static
void
Deal(
string
str)
{
string
mstr
=
Sort(str);
string
[] strs
=
DealF(mstr);
for
(
int
i
=
0
; i
<
strs.Length; i
++
)
Console.WriteLine(strs[i]);
}
static
string
[] DealF(
string
str)
{
if
(str.Length
==
1
)
return
new
string
[]
{ str }
;
if
(str.Length
==
2
)
{
string
[] toRets
=
new
string
[
2
];
toRets[
0
]
=
str;
toRets[
1
]
=
str.Substring(
1
)
+
str.Substring(
0
,
1
);
return
toRets;
}
string
c
=
str.Substring(
0
,
1
);
string
[] Ret
=
DealF(str.Substring(
1
));
string
[] toRet
=
new
string
[Ret.Length
*
2
];
for
(
int
i
=
0
; i
<
toRet.Length; i
++
)
{
if
(i
<
toRet.Length
/
2
)
toRet[i]
=
c
+
Ret[i];
else
toRet[i]
=
Ret[i
-
Ret.Length]
+
c;
}
return
toRet;
}
}
}
张旋(zxsoft)
如对本文有什么疑问,请在下面写下留言,谢谢!
查看全文
相关阅读:
MS CRM 2011的自定义和开发(10)——CRM web服务介绍(第一部分)——IDiscoveryService
MS CRM 2011的自定义和开发(7)——视图编辑器(第二部分)
MS CRM 2011 SDK 5.06版本已经发布
MS CRM 2011的自定义和开发(11)——插件(plugin)开发(一)
近来遇到的MS CRM 2011方面的几个问题
MS CRM 2011的自定义与开发(6)——表单编辑器(第二部分)
Microsoft Dynamics CRM 2011中,Lookup字段的赋值
MS CRM 2011的自定义和开发(6)——表单编辑器(第三部分)
Visual Studio 目标框架造成 命名空间“Microsoft”中不存在类型或命名空间名称“Crm”。是否缺少程序集引用中错误的处理
一步步学习Reporting Services(二) 在报表中使用简单的参数作为查询条件
原文地址:https://www.cnblogs.com/zxsoft/p/938082.html
最新文章
MS CRM 2011的自定义和开发(10)——CRM web服务介绍(第二部分)——IOrganizationService(一)
SDK5.0.13发布
MS CRM 2011的自定义和开发(8)——扩展框架以及扩展点介绍
MS CRM 2011汇总更新5发布
MS CRM 2011的自定义与开发(12)——表单脚本扩展开发(1)
Microsoft Dynamics CRM 2011 SDK 5.07版本已经发布
MS CRM 2011的自定义与开发(6)——表单编辑器(第一部分)
MS CRM 2011的自定义和开发(7)——视图编辑器(第一部分)
MS CRM 2011的自定义和开发(11)——插件(plugin)开发(四)
MS CRM 2011的自定义和开发(11)——插件(plugin)开发(三)
热门文章
MS CRM 2011的自定义和开发(10)——CRM web服务介绍(第二部分)——IOrganizationService(四)
MS CRM 2011的自定义和开发(11)——插件(plugin)开发(二)
MS CRM 2011的自定义与开发(12)——表单脚本扩展开发(5)
MS CRM 2011官方用户手册和管理员手册
MS CRM 2011的自定义与开发(12)——表单脚本扩展开发(3)
MS CRM 2011的自定义和开发(9)——编程模型介绍
MS CRM 2011 最近的一些更新
微软Dynamics CRM 2011 Rollup 12已经发布
MS CRM 2011 汇总更新4已经发布
MS CRM 2011的自定义和开发(10)——CRM web服务介绍(第二部分)——IOrganizationService(三)
Copyright © 2011-2022 走看看