From cbeb76c72ade669f13facb4495020ea868024e21 Mon Sep 17 00:00:00 2001 From: mdminhaziftekhar <70488121+mdminhaziftekhar@users.noreply.github.com> Date: Wed, 3 Feb 2021 16:03:16 +0600 Subject: [PATCH] Added a function for ease of understanding --- 266B - Queue at the School.cpp | 38 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/266B - Queue at the School.cpp b/266B - Queue at the School.cpp index 6939dbd..0d9d43f 100644 --- a/266B - Queue at the School.cpp +++ b/266B - Queue at the School.cpp @@ -1,26 +1,34 @@ //4021768 Jul 4, 2013 7:57:17 PM fuwutu 266B - Queue at the School GNU C++0x Accepted 15 ms 0 KB #include #include - using namespace std; -int main() -{ - int n, t; - string s; - cin >> n >> t >> s; - while (t--) - { - for (int i = 1; i < n; ++i) - { - if (s[i] == 'G' && s[i-1] == 'B') - { - s[i] = 'B'; - s[i-1] = 'G'; - ++i; +string swap_action(string str){ + for(int i = 1; i> student >> t; + cin.ignore(); + + getline(cin, s); + + for(; t > 0; t--){ + s = swap_action(s); } + cout << s << endl; + return 0; }