Untitled

public
6shootingstar9 Apr 06, 2025 Never 28
Clone
Markdown paste1.md 26 lines (24 loc) | 428 Bytes

这题也是非常的简单直接按照题面模拟就行。

具体的看代码注释吧。

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    string s;
    cin>>s;
    for(int j=1;j<=d;j++)
    {
        int i=n-1;//从盒子最右侧开始遍历
        while(s[i]!='@'&&i>0)
        {
            i--;
        }//只要这个格子不是饼干就继续往前找
        s[i]='.';
    }
    cout<<s;
    return 0;
}