PSUDOCODE:
START
READ s;
SET char d;
OPEN FILE "tweets.txt" in f
SET int c=0;
SET int count=0;
while(!f.eof())
f.get(d);
if(d==s[c])
c++;
else
c=0;
end if
if(c==strlen(s))
count++;
c=0;
end if
end while
print count
STOP
CODE:
#include<fstream>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
fstream f;
char s[100];
cin>>s;
char d;
f.open("tweets.txt",ios::in);
int c=0;
int count=0;
while(!f.eof())
{
f.get(d);
if(d==s[c])
{
c++;
}
else
{c=0;}
if(c==strlen(s))
{
count++;
c=0;
}
}
cout<<count;
return 0;
}
START
READ s;
SET char d;
OPEN FILE "tweets.txt" in f
SET int c=0;
SET int count=0;
while(!f.eof())
f.get(d);
if(d==s[c])
c++;
else
c=0;
end if
if(c==strlen(s))
count++;
c=0;
end if
end while
print count
STOP
CODE:
#include<fstream>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
fstream f;
char s[100];
cin>>s;
char d;
f.open("tweets.txt",ios::in);
int c=0;
int count=0;
while(!f.eof())
{
f.get(d);
if(d==s[c])
{
c++;
}
else
{c=0;}
if(c==strlen(s))
{
count++;
c=0;
}
}
cout<<count;
return 0;
}
No comments:
Post a Comment