博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zoj3501
阅读量:6273 次
发布时间:2019-06-22

本文共 1692 字,大约阅读时间需要 5 分钟。

ContractedBlock.gif
ExpandedBlockStart.gif
View Code
 
#include
<
iostream
>
#include
<
algorithm
>
#include
<
string
.h
>
#include
<
cstdio
>
using
namespace
std;
char
a[][
15
]
=
{
"
0
"
,
"
I
"
,
"
II
"
,
"
III
"
,
"
IV
"
,
"
V
"
,
"
VI
"
,
"
VII
"
,
"
VIII
"
,
"
IX
"
};
char
b[][
15
]
=
{
"
0
"
,
"
X
"
,
"
XX
"
,
"
XXX
"
,
"
XL
"
,
"
L
"
,
"
LX
"
,
"
LXX
"
,
"
LXXX
"
,
"
XC
"
};
char
c[][
15
]
=
{
"
0
"
,
"
C
"
,
"
CC
"
,
"
CCC
"
,
"
CD
"
,
"
D
"
,
"
DC
"
,
"
DCC
"
,
"
DCCC
"
,
"
CM
"
};
char
d[][
15
]
=
{
"
0
"
,
"
M
"
,
"
MM
"
,
"
MMM
"
};
struct
node
{
char
f[
15
];
char
ch[
15
];
}s[
10010
];
int
cmp(
const
void
*
x,
const
void
*
y)
{
return
strcmp( ((node
*
)x)
->
ch , ((node
*
)y)
->
ch );
}
int
main()
{
int
t,i,j;
int
n,m;
char
ch1[
10010
];
scanf(
"
%d
"
,
&
t);
while
(t
--
)
{
scanf(
"
%d
"
,
&
n);
for
(i
=
0
;i
<
n;i
++
)
{
scanf(
"
%s
"
,ch1);
strcpy(s[i].f, ch1);
int
L
=
strlen(ch1);
if
(L
==
4
)
{
strcpy(s[i].ch, d[ch1[
0
]
-
'
0
'
]);
if
(ch1[
1
]
!=
'
0
'
) strcat(s[i].ch, c[ch1[
1
]
-
'
0
'
]);
if
(ch1[
2
]
!=
'
0
'
) strcat(s[i].ch, b[ch1[
2
]
-
'
0
'
]);
if
(ch1[
3
]
!=
'
0
'
) strcat(s[i].ch, a[ch1[
3
]
-
'
0
'
]);
}
if
(L
==
3
)
{
strcpy(s[i].ch,c[ch1[
0
]
-
'
0
'
]);
if
(ch1[
1
]
!=
'
0
'
) strcat(s[i].ch, b[ch1[
1
]
-
'
0
'
]);
if
(ch1[
2
]
!=
'
0
'
) strcat(s[i].ch , a[ch1[
2
]
-
'
0
'
]);
}
if
(L
==
2
)
{
strcpy(s[i].ch , b[ch1[
0
]
-
'
0
'
]);
if
(ch1[
1
]
!=
'
0
'
) strcat(s[i].ch, a[ch1[
1
]
-
'
0
'
]);
}
if
(L
==
1
)
{
strcpy(s[i].ch,a[ch1[
0
]
-
'
0
'
]);
}
}
qsort(s,n,
sizeof
(s[
0
]), cmp);
for
(i
=
0
;i
<
n;i
++
)
{
printf(
"
%s
"
,s[i].f);
if
(i
!=
n
-
1
) printf(
"
"
);
}
printf(
"
\n
"
);
}
return
0
;
}

转载于:https://www.cnblogs.com/FCWORLD/archive/2011/05/01/2033962.html

你可能感兴趣的文章
算法竞赛入门经典 例题 3-2 蛇形填数
查看>>
remove-duplicates-from-sorted-list I&II——去除链表中重复项
查看>>
c++ 网络库
查看>>
Linux 格式化扩展分区(Extended)
查看>>
linux echo命令
查看>>
nginx 内置变量大全(转)
查看>>
lakala反欺诈建模实际应用代码GBDT监督学习
查看>>
java 解析excel工具类
查看>>
Google FireBase - fcm 推送 (Cloud Messaging)
查看>>
BBS论坛(二十七)
查看>>
html DOM 的继承关系
查看>>
装饰器的邪门歪道
查看>>
Dubbo常用配置解析
查看>>
【转】C#解析Json Newtonsoft.Json
查看>>
macports的安装及常用命令
查看>>
(转)使用C#开发ActiveX控件
查看>>
spring mvc 基于注解 配置默认 handlermapping
查看>>
半小时学会上传本地项目到github
查看>>
Android学Jni/Ndk 开发记录(一)
查看>>
Linux Tcl和Expect的安装
查看>>