Created
April 30, 2015 04:26
-
-
Save samir96/651ad13bf071c3992fd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <cstdlib> | |
#include <algorithm> | |
#include <fstream> | |
using namespace std; | |
void check_banana (string banana){ | |
ifstream AbrirBanana; | |
AbrirBanana.open(banana); | |
string col; | |
int n = 0; | |
while(AbrirBanana.tellg() != -1){ | |
AbrirBanana >> col; | |
for(int i = 0; i< col.size(); i++){ | |
if( (col[i] == 'B' or col[i] == 'b') and | |
(col[i+1] == 'A' or col[i+1] == 'a') and | |
(col[i+2] == 'N' or col[i+2] == 'n') and | |
(col[i+3] == 'A' or col[i+3] == 'a') and | |
(col[i+4] == 'N' or col[i+4] == 'n') and | |
(col[i+5] == 'A' or col[i+5] == 'a') ) | |
n++; | |
} | |
} | |
cout<<"La cantidad de veces que está escrita la palabra banana es: "<<n<<endl; | |
} | |
int main(){ | |
check_banana("banana.txt"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment