洛谷p1908题解
https://www.luogu.com.cn/problem/P1098#define _CRT_SECURE_NO_WARNINGS#include<iostream>#include<string>#include<cstring>#include<cstdio>using namespace std;int main(){char a[70
·
https://www.luogu.com.cn/problem/P1098
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
char a[7000] = { 0 };
char b[7000] = { 0 };
int p1, p2, p3;
cin >> p1 >> p2 >> p3;
cin>>a;
int log = 0;
int k = 0;
int flag=0;
for (int i = 0; i < strlen(a); i++){
if (a[i] == '-'){
// if(a[i+1]=='-') {
// b[k++] = a[i];
// continue;
//}
if(flag==0){
b[k++] = a[i];
continue;
}
if(i==0 || i==strlen(a)-1) {
b[k++] = a[i];
continue;
}
if (a[i-1] == a[i + 1] - 1){
}
if(a[i-1]==a[i+1]){
b[k++] = a[i];
}
if (a[i - 1] > a[i + 1]){
b[k++] = a[i];
}
if(isdigit(a[i-1])&&!isdigit(a[i+1])){
b[k++] = a[i];
continue;
}
flag=0;
if (p3 == 1){
for (int j = a[i-1]+1; j < a[i+1]; j++){
for (int m = 0; m < p2; m++){
switch (p1){
case 1:b[k++] = j; break;
case 2:if (isdigit(j)) b[k++] = j;else b[k++] = j - 32; break;
case 3:b[k++] = '*'; break;
}
}
}
}
if (p3 == 2){
for (int j = a[i+1]-1; j > a[i -1]; j--){
for (int m = 0; m < p2; m++){
switch (p1){
case 1:b[k++] = j; break;
case 2:if (isdigit(j)) b[k++] = j; else b[k++] = j - 32; break;
case 3:b[k++] = '*'; break;
}
}
}
}
}
else{
b[k++] = a[i];
flag=1;
}
}
cout << b << endl;
return 0;
}
}
更多推荐


所有评论(0)