-
Notifications
You must be signed in to change notification settings - Fork 0
/
program.cpp
42 lines (42 loc) · 1.2 KB
/
program.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
template <class T>
void beolvas(T &x) {
bool hiba;
do{
cin >> x;
hiba = cin.fail() || (cin.peek()!='\n' && cin.peek()!=' ');
if(hiba){
cout << "Nem megfelelo erteket adtal meg." << endl;
cin.ignore(1000,'\n');
}
cin.clear();
if(cin.peek()=='\n') cin.ignore(1,'\n');
}while(hiba);
}
template <class T , class N>
void beolvas(T &x, N min) {
bool hiba;
do{
cin >> x;
hiba = cin.fail() || (cin.peek()!='\n' && cin.peek()!=' ') || min > x;
if(hiba){
cout << "Nem megfelelo erteket adtal meg." << endl;
cin.ignore(1000,'\n');
}
cin.clear();
if(cin.peek()=='\n') cin.ignore(1,'\n');
}while(hiba);
}
template <class T, class N, class X>
void beolvas(T &x, N min, X max) {
bool hiba;
do{
cin >> x;
hiba = cin.fail() || (cin.peek()!='\n' && cin.peek()!=' ') || min > x || max < x;
if(hiba){
cout << "Nem megfelelo erteket adtal meg." << endl;
cin.ignore(1000,'\n');
}
cin.clear();
if(cin.peek()=='\n') cin.ignore(1,'\n');
}while(hiba);
}