#include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main() { int a; cin>>a; string s; cin>>s; int ile = a/10; int wynik = 0; int count = 0; bool x = true; for(int i=0;i<s.length();i++){ count++; if(s[i]=='N'){ x=false; } if(ile==count){ count=0; if(x==true){ wynik++; } x=true; } } cout<<wynik; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main() { int a; cin>>a; string s; cin>>s; int ile = a/10; int wynik = 0; int count = 0; bool x = true; for(int i=0;i<s.length();i++){ count++; if(s[i]=='N'){ x=false; } if(ile==count){ count=0; if(x==true){ wynik++; } x=true; } } cout<<wynik; return 0; } |