fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n,s;
  8. char tab[100];
  9. bool test;
  10. cin>>n;
  11. cin>>s;
  12. for(int i=0;i<n;i++)
  13. cin>>tab[i];
  14. for(int j=0;j<s;j++)
  15. {
  16. test=false;
  17. for(int i=0;i<n;i++)
  18. if (test)
  19. {
  20. test=false;
  21. continue;
  22.  
  23. }
  24. if((tab[i]=="B") && (tab[i+1]=="G"))
  25. {
  26. tab[i]='G';
  27. tab[i+1]='B';
  28. test=true;
  29.  
  30. }
  31. }
  32. for(int i=0;i<n;i++)
  33. cout<<tab[i];
  34. return 0;
  35. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:24:13: error: ‘i’ was not declared in this scope
     if((tab[i]=="B")  &&  (tab[i+1]=="G"))
             ^
stdout
Standard output is empty