Skip to content

Instantly share code, notes, and snippets.

@horvathgyozo
Created October 25, 2016 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horvathgyozo/ece9455ceb6384daa1a404ec337820d9 to your computer and use it in GitHub Desktop.
Save horvathgyozo/ece9455ceb6384daa1a404ec337820d9 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
void beolvas(int &n, string sz[100+1]) {
//2. be
bool jo;
do {
cout << "N=";
cin >> n;
jo = n>=0 && n<=100;
if (!jo) {
cout << "Nem jo" << endl;
}
} while(!jo);
for (int i = 1; i<=n; i++) {
do {
cout << i << ". szsz: ";
cin >> sz[i];
jo = sz[i].length() == 1 &&
(sz[i][0] == '1' ||
sz[i][0] == '2');
if (!jo) {
cout << "Nem jo" << endl;
}
} while(!jo);
}
}
void eldontes(const int n, const string sz[100+1],
bool &ferfi) {
//3. feld, alg
int i = 1;
while (i<=n && sz[i][0]!='1') {
i = i + 1;
}
ferfi = i<=n;
}
void kiir(const bool ferfi) {
//4. ki
if (ferfi) {
cout << "Van ffi" << endl;
} else {
cout << "Nincs ffi" << endl;
}
}
int main()
{
//1. dekl, beki
int n; //be
string sz[100+1]; //be
bool ferfi; //ki
beolvas(n, sz);
eldontes(n, sz, ferfi);
kiir(ferfi);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment