Files
lico/Solving/StringSegmentation.cpp

58 lines
1.5 KiB
C++
Raw Normal View History

2025-06-16 20:36:36 +08:00
#include "Questions.h"
/**
SN个-N+1K
K个字符组成新的子串-
:
KS
:
1
3
12abc-abCABc-4aB@
12abc-abc-ABC-4aB-@
*/
#include <iostream>
void StringSegmentation() {
std::string inputStr;
int inputNmb;
std::cin >> inputNmb;
std::cin >> inputStr;
std::string output;
int index = inputStr.find('-');
if (index == -1) {
return;
}
output = std::string(inputStr.begin(), inputStr.begin() + index + 1);
inputStr = inputStr.substr(index + 1);
std::string tmpStr{};
index = inputStr.find('-');
while (index != -1) {
tmpStr += inputStr.substr(0, index);
inputStr = inputStr.substr(index + 1);
index = inputStr.find('-');
}
tmpStr += inputStr;
for (auto i: tmpStr) {
int low{}, up{}, cnt{};
std::string lowStr = "-";
std::string upStr = "-";
if (i >= 'a' && i <= 'z') {
++low;
lowStr.push_back(i);
upStr.push_back(i + 26);
}
else if (i >= 'A' && i <= 'z')
}
std::cout << output;
}