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
|
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <conio.h>
#include <iomanip>
#include <windows.h>
using namespace std;
int insertINT(char mes[256])
{
int value;
cout<<mes;
cin>>value;
return value;
}
int abc(int a, int b, int c) // a+b-c
{
return a+b-c;
}
void showINT(char mes[256],int R)
{
cout<<mes<<R<<endl;
}
int sum(int R, int s) //sum of the results a+b-c
{
return R+s;
}
int contor(int co) // counter
{
co++;
return co;
}
int parity(int R, int even, int odd) // parity check
{
if(R%2==0)
{
even++; cout<<"even";
}
else
{
odd++; cout<<"odd";
}
return R%2==0? even: odd;
}
int main()
{
srand(time(0));
int p, even=0, odd=0, co=0, cp, suma=0, a,b,c, n = insertINT("Enter n=");
for(int i=0; i<n; i++)
{
showINT("\n iteration nr.=",i+1);
a = insertINT("Enter a=");
b = insertINT("Enter b=");
c = insertINT("Enter c=");
suma = sum( abc(a,b,c) ,suma);
if( suma < 10 ){
cp=contor( co); }
showINT("Result of a+b-c=", abc(a,b,c) );
showINT(" a+b-c ", parity(abc(a,b,c), even,odd));
}
cout << " suma = "<<suma<<endl;
cout << " The results of equation were smaller than 10 for "<<cp<<" times"<<endl;
return 0;
}
|