题解
2023-03-11 22:16:46
发布于:上海
#include<iostream>
using namespace std;
struct CNode
{
CNode()
{
c = '\0';
pNext = NULL;
}
~CNode(){}
char c;
CNode* pNext;
};
CNode* pHead = new CNode();
CNode* pEnd = pHead;
CNode* phead = NULL;
CNode* pend = NULL;
CNode* node = NULL;
char str = '\0';
int p1 = 0;
int p2 = 0;
int p3 = 0;
int main()
{
cin>>p1>>p2>>p3;
cin>>str;
pHead->c = str;
while(cin>>str)
{
node = new CNode();
node->c = str;
pEnd->pNext = node;
pEnd = pEnd->pNext;
}
CNode* p = pHead;
while(p->pNext != NULL && p->pNext->pNext != NULL)
{
if(p->pNext->c == '-')
{
if(p->c >= '0' && p->c <= '9' && p->pNext->pNext->c >= '0' && p->pNext->pNext->c <= '9')
{
if(p->pNext->pNext->c - p->c == 1)
{
node = p->pNext;
p->pNext = p->pNext->pNext;
}
else if(p->pNext->pNext->c - p->c > 0)
{
if(p3 == 1)
{
if(p1 == 1 || p1 == 2)
{
phead = new CNode();
pend = phead;
for(char i = p->c + 1;i < p->pNext->pNext->c;i++)
{
for(int j = 1;j <= p2;j++)
{
node = new CNode();
node->c = i;
pend->pNext = node;
pend = pend->pNext;
}
}
node = p->pNext;
pend->pNext = p->pNext->pNext;
p->pNext = phead->pNext;
}
else
{
phead = new CNode();
pend = phead;
for(char i = p->c + 1;i < p->pNext->pNext->c;i++)
{
for(int j = 1;j <= p2;j++)
{
node = new CNode();
node->c = '*';
pend->pNext = node;
pend = pend->pNext;
}
}
node = p->pNext;
pend->pNext = p->pNext->pNext;
p->pNext = phead->pNext;
}
}
else
{
if(p1 == 1 || p1 == 2)
{
phead = new CNode();
pend = phead;
for(char i = p->pNext->pNext->c - 1;i > p->c;i--)
{
for(int j = 1;j <= p2;j++)
{
node = new CNode();
node->c = i;
pend->pNext = node;
pend = pend->pNext;
}
}
node = p->pNext;
pend->pNext = p->pNext->pNext;
p->pNext = phead->pNext;
}
else
{
phead = new CNode();
pend = phead;
for(char i = p->pNext->pNext->c - 1;i > p->c;i--)
{
for(int j = 1;j <= p2;j++)
{
node = new CNode();
node->c = '*';
pend->pNext = node;
pend = pend->pNext;
}
}
node = p->pNext;
pend->pNext = p->pNext->pNext;
p->pNext = phead->pNext;
}
}
}
}
else if(p->c >= 'a' && p->c <= 'z' && p->pNext->pNext->c >= 'a' && p->pNext->pNext->c <= 'z')
{
if(p->pNext->pNext->c - p->c == 1)
{
node = p->pNext;
p->pNext = p->pNext->pNext;
}
else if(p->pNext->pNext->c - p->c > 0)
{
if(p3 == 1)
{
if(p1 == 1)
{
phead = new CNode();
pend = phead;
for(char i = p->c + 1;i < p->pNext->pNext->c;i++)
{
for(int j = 1;j <= p2;j++)
{
node = new CNode();
node->c = i;
pend->pNext = node;
pend = pend->pNext;
}
}
node = p->pNext;
pend->pNext = p->pNext->pNext;
p->pNext = phead->pNext;
}
else if(p1 == 2)
{
phead = new CNode();
pend = phead;
for(char i = p->c + 1;i < p->pNext->pNext->c;i++)
{
for(int j = 1;j <= p2;j++)
{
node = new CNode();
node->c = i - 32;
pend->pNext = node;
pend = pend->pNext;
}
}
node = p->pNext;
pend->pNext = p->pNext->pNext;
p->pNext = phead->pNext;
}
else
{
phead = new CNode();
pend = phead;
for(char i = p->c + 1;i < p->pNext->pNext->c;i++)
{
for(int j = 1;j <= p2;j++)
{
node = new CNode();
node->c = '*';
pend->pNext = node;
pend = pend->pNext;
}
}
node = p->pNext;
pend->pNext = p->pNext->pNext;
p->pNext = phead->pNext;
}
}
else
{
if(p1 == 1)
{
phead = new CNode();
pend = phead;
for(char i = p->pNext->pNext->c - 1;i > p->c;i--)
{
for(int j = 1;j <= p2;j++)
{
node = new CNode();
node->c = i;
pend->pNext = node;
pend = pend->pNext;
}
}
node = p->pNext;
pend->pNext = p->pNext->pNext;
p->pNext = phead->pNext;
}
else if(p1 == 2)
{
phead = new CNode();
pend = phead;
for(char i = p->pNext->pNext->c - 1;i > p->c;i--)
{
for(int j = 1;j <= p2;j++)
{
node = new CNode();
node->c = i - 32;
pend->pNext = node;
pend = pend->pNext;
}
}
node = p->pNext;
pend->pNext = p->pNext->pNext;
p->pNext = phead->pNext;
}
else
{
phead = new CNode();
pend = phead;
for(char i = p->pNext->pNext->c - 1;i > p->c;i--)
{
for(int j = 1;j <= p2;j++)
{
node = new CNode();
node->c = '*';
pend->pNext = node;
pend = pend->pNext;
}
}
node = p->pNext;
pend->pNext = p->pNext->pNext;
p->pNext = phead->pNext;
}
}
}
}
}
p = p->pNext;
}
p = pHead;
while(p != NULL)
{
cout<<p->c;
p = p->pNext;
}
return 0 ;
}
这里空空如也
有帮助,赞一个