码迷,mamicode.com
首页 > 编程语言 > 详细

C++ question

时间:2018-07-22 00:10:47      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:child   adjust   -o   mes   form   com   res   .so   situation   

The set of written test question

Question1:Adjustment Queue

  • In the kindergarten,there are n children arranged in a team,with one number from left to right(0~n-1).Some of them are boys,some are girl,boys are represented by ‘B‘,and girls are indicated by ‘G‘.The children are very naughty,and when a boy is squattion with a girl,there will be contradiction.As a kindergarten teacher,you need to let the boys take the girls or girls to the least.You cna only make adjustmentson the original formation.Each adjustment can only allow the two adjacent childrento exchange positions.Now you need to complete the team adjustment as soon as possible.You need to calculate the minimum number of adjustments you need to make the situation the least.For example:GGBBG->GGBGB->GGGBB
    This will make the previous two male and female neighbors become adjacent,and need to adjust the formation 2 times.
    Enter a description:
    The input data includes a string of length n and containing only G and B.n does not exceed 50.
    Output description:
    Output an integer indicating the minimum number of adjustments required for the team.
    Input example:
    Output example:
    2

C++ question

标签:child   adjust   -o   mes   form   com   res   .so   situation   

原文地址:https://www.cnblogs.com/hugeng007/p/9348444.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!