传送门

一个模拟。

代码

#include <cstdio>
#include <cstring>
#include <iostream>
#define isword(x) ((x) >= 'a' && (x) <= 'z')
#define swap(x, y) ((x) ^= (y) ^= (x) ^= (y)) int n, p1, p2, p3, add, d, start, end;
char s[1000001]; int main()
{
int i, j, k;
scanf("%d %d %d", &p1, &p2, &p3);
scanf("%s", s + 1);
n = strlen(s + 1);
for(i = 1; i <= n; i++)
{
if(s[i] != '-' || i == 1 || i == n || (isword(s[i - 1]) && isdigit(s[i + 1])) || (isdigit(s[i - 1]) && isword(s[i + 1])) || (s[i] == '-' && (s[i - 1] == '-' || s[i + 1] == '-'))) putchar(s[i]);
else
{
if(s[i - 1] + 1 == s[i + 1]) continue;
if(s[i - 1] >= s[i + 1])
{
putchar('-');
continue;
}
add = 0;
d = 1;
start = s[i - 1] + 1;
end = s[i + 1];
if(p3 == 2) swap(start, end), start -= 1, end -= 1, d = -1;
if(p1 == 3)
{
for(j = 1; j <= p2; j++)
for(k = start; k != end; k += d) putchar('*');
continue;
}
if(isword(s[i - 1]) && p1 == 2) add -= 32;
for(k = start; k != end; k += d)
for(j = 1; j <= p2; j++)
putchar(k + add);
}
}
return 0;
}

  

[luoguP1098] 字符串的展开(模拟)的更多相关文章

  1. Luogu 1098 - 字符串的展开 - [字符串操作][模拟]

    题目链接:https://www.luogu.org/problemnew/show/P1098 题目描述在初赛普及组的“阅读程序写结果”的问题中,我们曾给出一个字符串展开的例子:如果在输入的字符串中 ...

  2. 洛谷P1098 字符串的展开【字符串】【模拟】

    题目描述 在初赛普及组的“阅读程序写结果”的问题中,我们曾给出一个字符串展开的例子:如果在输入的字符串中,含有类似于“d-h”或者“4-8”的字串,我们就把它当作一种简写,输出时,用连续递增的字母或数 ...

  3. noip200706字符串的展开

    试题描述: 在初赛普及组的“阅读程序写结果”的问题中,我们曾给出一个字符串展开的例子:如果在输入的字符串中,含有类似于“d-h”或者“4-8”的字串,我们就把它当作一种简写,输出时,用连续递增的字母获 ...

  4. 洛谷 P1098 字符串的展开

    题目描述 在初赛普及组的“阅读程序写结果”的问题中,我们曾给出一个字符串展开的例子:如果在输入的字符串中,含有类似于“d-h”或者“4-8”的字串,我们就把它当作一种简写,输出时,用连续递增的字母或数 ...

  5. 洛谷——P1098 字符串的展开

    P1098 字符串的展开 题目描述 在初赛普及组的“阅读程序写结果”的问题中,我们曾给出一个字符串展开的例子:如果在输入的字符串中,含有类似于“d-h”或者“4-8”的字串,我们就把它当作一种简写,输 ...

  6. 洛谷—— P1098 字符串的展开

    https://www.luogu.org/problem/show?pid=1098 题目描述 在初赛普及组的“阅读程序写结果”的问题中,我们曾给出一个字符串展开的例子:如果在输入的字符串中,含有类 ...

  7. [NOIP2007] 提高组 洛谷P1098 字符串的展开

    题目描述 在初赛普及组的“阅读程序写结果”的问题中,我们曾给出一个字符串展开的例子:如果在输入的字符串中,含有类似于“d-h”或者“4-8”的字串,我们就把它当作一种简写,输出时,用连续递增的字母获数 ...

  8. 【b702】字符串的展开

    Time Limit: 1 second Memory Limit: 50 MB [问题描述] 在初赛普及组的"阅读程序写结果"的问题中,我们曾给出一个字符串展开的例子:如果在输入 ...

  9. [Noip2007] 字符串的展开

    题目描述 在初赛普及组的“阅读程序写结果”的问题中,我们曾给出一个字符串展开的例子:如果在输入的字符串中,含有类似于“d-h”或者“4-8”的字串,我们就把它当作一种简写,输出时,用连续递增的字母或数 ...

随机推荐

  1. C# 操作Access的Ole对象[转]

    原文链接 OLE对象数据类型 (1)OLE 对象用于使用 OLE 协议在其他程序中创建的 OLE 对象,如 Microsoft Word 文档. Microsoft Excel 电子表格.图片.声音或 ...

  2. 472 Concatenated Words 连接的单词

    详见:https://leetcode.com/problems/concatenated-words/description/ C++: class Solution { public: vecto ...

  3. poj1781In Danger(约瑟夫) 问题

    链接 之前队内赛中的一道题目 当时怎么想也没想到,就一直放到了今天,刚才看另一题的讲解突然看到时拿这个题作为引子来讲的,就仔细看了下. 参考<<具体数学>> p7. Josep ...

  4. [转]Keyword Reference (F#)

    Visual F# Development Portal http://msdn.microsoft.com/en-us/library/vstudio/ff730280.aspx 本文转自:http ...

  5. LN : leetcode 70 Climbing Stairs

    lc 70 Climbing Stairs 70 Climbing Stairs You are climbing a stair case. It takes n steps to reach to ...

  6. hihocoder offer收割编程练习赛11 A hiho字符串

    思路: 我用的尺取. 注意题目描述为恰好2个'h',1个'i',1个'o'. 实现: #include <iostream> #include <cstdio> #includ ...

  7. visual assist x 注释配置

    /******************************************************************** created: $DATE$ created: $DAY$ ...

  8. mybatis-paginator对SqlServer分页实现

    package com.github.miemiedev.mybatis.paginator.dialect; import com.github.miemiedev.mybatis.paginato ...

  9. 【转】nABC法-产品分析思路

    Needs:需求N1,用户最基本需求是什么?N2,市场有多大?N3,行业链如何构成?N4,行业发展趋势如何?N5,扩充的需求有哪些? Approach:解决方案A1,解决方案如何构成?A2,需求优先级 ...

  10. python3.x 判断当前版本【简单版】

    import sys,string Major_Version_Number = 0 #当前python的主版本 Minor_Version_Number = 0 #当前python的次版本 def ...