竞赛
考级
#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; }
法兰西玫瑰
看着很复杂的一道模拟题,虽然写起来确实不怎么复杂,但细节还是比较多的. 主要分析的就是-的处理情况,总体上就是展开和不展开(直接输出)的判断. 需要展开的情况: 前后有字符,且均为字母或数字 字符后者-前者的ascii值>=1 (=1时仍然是展开,但什么都不输出.我是用了个特判,但想想好像也不需要) 那么不展开的情况就是非上述情况了.包括首尾,前后不为相同类型,甚至还有一堆-相连的一个测试点 我还纳闷为啥还有90分这种情况 总体上还是判断写的太渣了,但我又懒得改,开摆! AC代码 欢迎加入团队
唱跳坤
ACGO数据水,洛谷WA3个点,ACGO全AC
不想AC
非常好的一道模拟题。 纯模拟就行,把脑子拿出来寄存一下,然后无脑模拟就行。
zhouty
影响输出的是p1和p3,p2其实无关紧要,只要在循环输出的时候作为边界即可。
AC君
题库管理员
一个if,写了四行 很长的if,在我的编辑栏里长四行
Simpletense