Created
November 22, 2015 03:17
-
-
Save ChrisOrozco97/9bf1da6e9e0f84900cb6 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 <fstream> | |
using namespace std; | |
int main(){ | |
string read; | |
char file[50]; | |
int index = 0; | |
int index2 = 0; | |
int count = 0; | |
cout << "Escribe el nombre de tu documento: "; | |
cin >> file; | |
ifstream read_file (file); | |
if (read_file.is_open()){ | |
while (getline(read_file , read)){ | |
index = 0; | |
while (index < read.length()) { | |
char letter = read[index]; | |
if ( letter == 'B' || letter== 'b'){ | |
index2 = index + 1; | |
char letter = read[index2]; | |
if (letter == 'A' || letter== 'a'){ | |
index2++; | |
char letter = read[index2]; | |
if (letter == 'N' || letter== 'n'){ | |
index2++; | |
char letter = read[index2]; | |
if (letter == 'A' || letter== 'a'){ | |
index2++; | |
char letter = read[index2]; | |
if (letter == 'N' || letter== 'n'){ | |
index2++; | |
char letter = read[index2]; | |
if (letter == 'A' || letter== 'a') { | |
count++; | |
} | |
} | |
} | |
} | |
} | |
} | |
index = index + 1; | |
} | |
} | |
read_file.close(); | |
}else{ | |
cout << "Failed opening the file" << endl; | |
} | |
cout << "found " << count << " bananas" << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment