Skip to content

Instantly share code, notes, and snippets.

@mAlishera
Last active April 10, 2017 19:28
Show Gist options
  • Save mAlishera/e1e5b0bacd98ddebae8d5c1fb3da21e8 to your computer and use it in GitHub Desktop.
Save mAlishera/e1e5b0bacd98ddebae8d5c1fb3da21e8 to your computer and use it in GitHub Desktop.
считает количество гласных в строках файла и выводит строку с максимальным количеством
#include <string>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main()
{
int ii(0), max(0);
char c;
string str, b;
ifstream r;
r.open("st.txt");
while (!r.eof()) {
while(getline(r, str)) {
istringstream ss(str);
while(ss >> c) {
if ((c == 'a') || (c == 'e') || (c == 'u') || (c == 'i') || (c == 'o') || (c == 'y')) {
ii++;
}
}
cout << ii;
cout<<endl;
if (ii>max) {
max = ii;
b = str;
ii = 0;
}
}
}
cout << b;
cout<<endl;
r.close();
cout<<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment