Created
May 2, 2017 17:07
-
-
Save Adals20/63be5cd1d070099efd1d575230e6eb3e 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 <fstream> | |
using namespace std; | |
int LineasBananas(string lineas){ | |
int x=0, bananas=0; | |
for(int i=0; i<lineas.length(); i++){ | |
lineas[i] = tolower(lineas[i]); | |
} | |
//cout << lineas; | |
while(1){ | |
int foundtop = lineas.find("banana", x); | |
x = foundtop + 1; | |
if (foundtop != -1){ | |
bananas++; | |
}else{ | |
//cout<<"Contador: "<<bananas<<endl; | |
break; | |
} | |
} | |
return bananas; | |
} | |
int EncuentraBananas(const char *filename){ | |
int contador =0; | |
string lineas; | |
ifstream file(filename); | |
if(file.is_open()){ | |
while(getline(file,lineas)){ | |
contador = contador + LineasBananas(lineas); | |
} | |
return contador; | |
} | |
} | |
main(){ | |
string filename = "Banana.txt"; | |
int veces; | |
veces = EncuentraBananas(filename.c_str()); | |
cout << "Usted tiene " << veces << " Bananas en su texto\n"; | |
cout <<" ____ ___\n"; | |
cout <<" | _ \ ___ _ _.' _ `.\n"; | |
cout <<" _ | [_) )' _ `._ _ ___ ! \ | | (_) | _\n"; | |
cout <<" |:;.| _ <| (_) | \ | |' _ `| \| | _ | .:;|\n"; | |
cout <<" | `.[_) ) _ | \| | (_) | | | | |.',..|\n"; | |
cout <<" ':. `. /| | | | | _ | |\ | | |.' :;::'\n"; | |
cout <<" !::, `-!_| | | |\ | | | | | \ !_!.' ':;!\n"; | |
cout <<" !::; ::;:!.!.\_!_!_!.!-'-':;:'' '''!\n"; | |
cout <<" ';:' `::;::;' '' ., .\n"; | |
cout <<" `: .,. `' .::... . .::;::;'\n"; | |
cout <<" `..:;::;:.. ::;::;:;:;, :;::;'\n"; | |
cout <<" '-:;::;:;: ':;::;:'' ;.-'\n"; | |
cout <<" ""`---...________...---'""\n"; | |
cout <<"\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment