codeforces-Interview with Oleg<水>

thinking:用for循环每个字符遇到第一个ogo,将其三个位置改为***,然后i+2,(然后此时的i与i+2是否为"g""o",如果是i又加2)把括号内的循环,在这句结束时,I--,是因为这句话完,

因为for的循环,i又加一次,这样是为了抵消.

failure:1、用循环将后面的值改变时,需要考虑循环到后面时这个值该如何改变。

2、把思路理清,新别太着急,认真一些

A. Interview with Oleg
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.

There is a filler word ogo in Oleg's speech. All words that can be obtained from ogo by adding go several times to the end of it are also considered to be fillers. For example, the words ogoogogoogogogo are fillers, but the words googogogogogog and oggo are not fillers.

The fillers have maximal size, for example, for ogogoo speech we can't consider ogo a filler and goo as a normal phrase. We should consider ogogo as a filler here.

To print the interview, Polycarp has to replace each of the fillers with three asterisks. Note that a filler word is replaced with exactly three asterisks regardless of its length.

Polycarp has dealt with this problem in no time. Can you do the same? The clock is ticking!

Input

The first line contains a positive integer n (1 ≤ n ≤ 100) — the length of the interview.

The second line contains the string s of length n, consisting of lowercase English letters.

Output

Print the interview text after the replacement of each of the fillers with "***". It is allowed for the substring "***" to have several consecutive occurences.

Examples
input
7
aogogob
output
a***b
input
13
ogogmgogogogo
output
***gmg***
input
9
ogoogoogo
output
*********
Note

The first sample contains one filler word ogogo, so the interview for printing is "a***b".

The second sample contains two fillers ogo and ogogogo. Thus, the interview is transformed to "***gmg***".

代码:

#include <bits/stdc++.h>


using namespace std;


int main(){
char a[210];
char b[210];
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
int n;
cin >> n; 
cin >> a;
int length=strlen(a);
int j=0;
for(int i=0;i<length;i++){
if(a[i]=='g'&&a[i-1]=='o'&&a[i+1]=='o'){
b[i-1]='*'; 
b[i]='*';
b[i+1]='*';     
i=i+2;           
while(a[i]=='g'&&a[i+1]=='o'){
i=i+2;       
}
i=i-1;
}else{
b[i]=a[i];
}
}
for(j=0;j<=length;j++)
if(b[j]!=0){
cout << b[j];}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以通过以下方式来添加日期和参与比赛总数接口: 1. 首先,从数据库中获取日期和参与比赛总数的数据。您可以使用适当的查询语句从数据库中检索这些数据。 2. 在`Codeforces`实体类中添加日期和参与比赛总数的属性,并生成对应的getter和setter方法。 3. 修改`Codeforces`实体类的`selectAll`方法,将获取到的日期和参与比赛总数数据设置到返回的`Codeforces`对象中。 4. 最后,将修改后的`Codeforces`对象添加到`Page<Codeforces>`中,并将`Page<Codeforces>`对象作为返回值返回。 下面是修改后的代码示例: ```java @Api(tags = "Codeforces") @RestController @RequestMapping("/acmer/codeforces") public class CodeforcesController { @Resource private CodeforcesServiceImpl codeforcesService; @ApiOperation("查询全部学生Codeforces信息") @ApiImplicitParams({ @ApiImplicitParam(name = "currentPage",value = "当前页数",required = true), @ApiImplicitParam(name = "pageSize",value = "页面大小",required = true) }) @GetMapping("/all/{currentPage}/{pageSize}") public PublicProperty<Page<Codeforces>> selectAll(@PathVariable("currentPage") Integer currentPage, @PathVariable("pageSize") Integer pageSize){ Page<Codeforces> page = new Page<>(currentPage, pageSize); // 从数据库中获取日期和参与比赛总数的数据 List<Codeforces> codeforcesList = codeforcesService.page(page).getRecords(); for (Codeforces codeforces : codeforcesList) { // 设置日期和参与比赛总数到Codeforces对象中 // 这里假设数据库中的日期字段为date,参与比赛总数字段为participateCount codeforces.setDate(/*从数据库获取的日期*/); codeforces.setParticipateCount(/*从数据库获取的参与比赛总数*/); } return new PublicProperty(200,"success", codeforcesService.page(page)); } } ``` 请注意,您需要根据您的实际情况修改代码中的注释部分以正确地获取日期和参与比赛总数的数据,并设置到`Codeforces`对象中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值