Advertisement
add1ctus

Електрични светилки

Feb 20th, 2015
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. char smeni(char a)
  7. {
  8.     if(a=='Y')
  9.         return 'N';
  10.     return 'Y';
  11. }
  12.  
  13. int main()
  14. {
  15.     string input;
  16.     cin>>input;
  17.     int rezultat=0;
  18.     for(int j=0;j<input.size();j++)
  19.         if(input[j]=='Y')
  20.         {
  21.             for(int k=j;k<input.size();k+=(j+1))
  22.                 input[k]=smeni(input[k]);
  23.             rezultat++;
  24.         }
  25.     cout<<rezultat;
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement