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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
#include <iostream>
using namespace std;
void classify (int,int,int);
bool validset(int,int,int);
bool validOrNot(void);
int main()
{
int valid = 0;
int invalid = 0;
int x,y,z;
char answer;
int total = 0;
bool validsetResult;
do {
cout << "Type in the first score" << endl;
cin >> x;
cout << "Type in the second score" << endl;
cin >> y;
cout << "Type in the third score" << endl;
cin >> z;
total++;
if(validOrNot() == false)
{
cout << "The group is invalid" << endl;
invalid++;
}
else if(validOrNot() == true)
{
cout << "The group is valid" << endl;
valid++;
}
if (validset(x, y, z) == true)
classify (x,y,z);
else;
cout << "Type c to continue; s to stop";
cin >> answer;
} while (answer == 'c');
cout << total << " total" << endl;
cout << valid << " valid" << endl;
cout << invalid << " invalid" << endl;
return 0;
}
bool validset(int x, int y, int z)
{
int vali = 0;
int invali = 0;
if (x < 0 || x > 300)
{
cout << "The group is invalid" << endl;
invali++;
return(false);
}
else if (y < 0 || y > 300)
{
cout << "The group is invalid" << endl;
invali++;
return(false);
}
else if (z < 0 || z > 300)
{
cout << "The group is invalid" << endl;
invali++;
return(false);
}
else
{
vali++;
return(true);
cout << vali;
cout << invali;
}
return(false);
}
void classify(int x, int y, int z)
{
cout << "success" << endl;
return ;
}
bool validOrNot(void)
{
int x, y, z;
if(validset(x, y, z))
{
return true;
}
else if(validset(x, y, z) == true)
{
return false;
}
}
|