zoukankan      html  css  js  c++  java
  • Codeforces Round #242 (Div. 2) A. Squats

    注意题目一次只能改变一个松鼠,Pasha can make some hamster ether sit down or stand up.是单数不是复数

    #include <iostream>
    #include <string>
    #include <vector>
    #include <algorithm>
    #include <cmath>
    using namespace std;
    
    int main(){
        int n;       cin >> n;
        string str;  cin >> str;
        int num =  count(str.begin(),str.end(),'X') -n/2;
        if(num == 0) cout<<0<<"
    "<<str<<endl;
        else{
            cout<<abs(num)<<endl;
            int cnt = 0;
            for(int i = 0 ;i < n && cnt<abs(num); ++ i){
                if(num > 0 && str[i]=='X'){
                    str[i]='x';
                    cnt++;
                }
                if(num < 0 && str[i]=='x'){
                    str[i]='X';
                    cnt++;
                }
            }
            cout<<str<<endl;
        }
    }
  • 相关阅读:
    有序向量
    无序向量
    设计模式入门
    策略模式
    面向对象相关知识点
    MySQL数据库知识培训
    数据库业务规范
    go最小路径
    go求质数
    CSS3
  • 原文地址:https://www.cnblogs.com/xiongqiangcs/p/3689366.html
Copyright © 2011-2022 走看看