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
|
#include "stdafx.h"
#include "../../std_lib_facilities.h"
double min_coordenation(double x, double y, double h)
{
double min = h;
if (y == 0) {
min = x;
}
else if (x < min)
min = x;
else {}
return min;
}
double max_coordenation(double x, double y, double h)
{
double max = h;
if (y == 0) {
max = x;
}
else if (x > max)
max = x;
else {}
return max;
}
int main()
{
double upper = 0;
double downer = 0;
double total = 0;
int count = 0;
char unit = '?';
vector<double> list;
for (double num = 0; cin >> num >> unit; ++count) {
switch (unit)
{
case 'c': //cm
num = num / 100;
list.push_back(num);
total += num;
downer = min_coordenation(num, count, downer);
upper = max_coordenation(num, count, upper);
break;
case 'm': //m
list.push_back(num);
total += num;
downer = min_coordenation(num, count, downer);
upper = max_coordenation(num, count, upper);
break;
case 'i': //in
num = num * 2.54 / 100;
list.push_back(num);
total += num;
downer = min_coordenation(num, count, downer);
upper = max_coordenation(num, count, upper);
break;
case 'f': //ft
num = num * 12 * 2.54 / 100;
list.push_back(num);
total += num;
downer = min_coordenation(num, count, downer);
upper = max_coordenation(num, count, upper);
break;
default:
cout << "illegal unit\n";
break;
}
}
cout << "Smallest: " << downer << "m\n";
cout << "Largest: " << upper << "m\n";
cout << "Number of inputs: " << count << "\n";
cout << "Total: " << total << "m\n";
cout << "Vector list:\n";
for (int w = 1; cout << list[w - 1] << "\t\t\t\t"; ++w) {
if (w % 2 == 0)
cout << "\n";
else {}
}
cout << "\n";
keep_window_open();
return 0;
}
|