The purpose of this article is to count the number of times a word appears in the article.
Implementation code:
#include <iostream> #include <string> #include <cstdio> using
namespace Std;
void Main () {freopen ("In.txt", "R", stdin);
Freopen ("OUT.txt", "w", stdout);
String Word,paper;
Getline (Cin,word);
Getline (Cin,paper);
Short Len1=word.size ();
Short Len2=paper.size ();
Short I,sum (0);
for (i=0;i<=len1-1;i++) {if (word[i]>=65&&word[i]<=90) word[i]+=32;
for (i=0;i<=len2-len1;i++) {if (paper[i]>=65&&paper[i]<=90) paper[i]+=32;
if (Paper[i]==word[0]) {short J;
bool Bo (1);
for (j=1;j<=len1-1;j++) {if (paper[i+j]>=65&&paper[i+j]<=90) paper[i+j]+=32;
if (Paper[i+j]!=word[j]) bo=0;
} if (bo==1) {sum++;
if (sum==1) cout<<i<< ';
}}} cout<<sum<<endl;
Fclose (stdin);
Fclose (stdout); }
The above is the entire content of this article, I hope to help you learn.