-
Notifications
You must be signed in to change notification settings - Fork 0
/
洛谷P1098 [NOIP2007 提高组] 字符串的展开.cpp
59 lines (58 loc) · 1.2 KB
/
洛谷P1098 [NOIP2007 提高组] 字符串的展开.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Problem: P1098 [NOIP2007 提高组] 字符串的展开
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1098
// Memory Limit: 125 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<iostream>
using namespace std;
int main(){
int p_1,p_2,p_3;
char p[101];
scanf("%d%d%d%s",&p_1,&p_2,&p_3,&p);
int i=0;
while(p[i]){
if(p[i]=='-'&&p[i-1]<p[i+1]&&(((p[i-1]>='a'&&p[i-1]<='z')&&(p[i+1]>='a'&&p[i+1]<='z'))||((p[i-1]>='0'&&p[i-1]<='9')&&(p[i+1]>='0'&&p[i+1]<='9')))){
if(p_1==3){
for(int o=p[i-1]+1;o<=p[i+1]-1;o++){
for(int pp=1;pp<=p_2;pp++){
printf("*");
}
}
i++;
continue;
}
if(p_3==1){
for(char tmpp=p[i-1]+1;tmpp<p[i+1];tmpp++){
char tmppp=tmpp;
if(p_1==2){
if(p[i-1]>='a'&&p[i-1]<='z')
tmppp-=32;
}
for(int o=1;o<=p_2;o++){
printf("%c",tmppp);
}
}
i++;
continue;
}else if(p_3==2){
for(char tmpp=p[i+1]-1;tmpp>p[i-1];tmpp--){
char tmppp=tmpp;
if(p_1==2){
if(p[i-1]>='a'&&p[i-1]<='z')
tmppp-=32;
}
for(int o=1;o<=p_2;o++){
printf("%c",tmppp);
}
}
i++;
continue;
}
}
printf("%c",p[i]);
i++;
}
return 0;
}