Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- using namespace std;
- int check(string &s);
- int action=0;
- int main()
- {
- ifstream ckk;
- ckk.open("t.txt");
- string s;
- int sum=0;
- while(getline(ckk,s)){
- for(int i=0;i<1;i++){
- sum+=check(s);
- if(sum%9000==0){
- cout<<sum;
- cout<<"\n"<<action;
- //cout<<system("CLS");
- //cout<<system("dir/s");
- cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
- }
- }
- }
- cout<<"SUM: "<<sum<<endl;
- cout<<"Chars: "<<action<<endl;
- }
- int check(string &s){
- bool word=true;
- int n=0;
- bool endOfWord=true;
- for(int i=0;i<s.size();i++){
- action++;
- if(s[i]!=' ')
- word=true;
- else word=false;
- if(word){
- if(i+1==s.size()){
- endOfWord=true;
- word=false;
- }
- else if(i+1<s.size() and s[i+1]==' '){
- endOfWord=true;
- word=false;
- }
- }
- if(endOfWord){
- ++n;
- endOfWord=false;
- }
- }
- if(s[0]!=' ')
- n++;
- if(s.size()>1)
- if(s[0]!=' ' && s[1]!=' ')
- n--;
- return n-1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement