-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntegerSorting.cpp
More file actions
113 lines (71 loc) · 2.13 KB
/
IntegerSorting.cpp
File metadata and controls
113 lines (71 loc) · 2.13 KB
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
110
111
112
113
//Homework 2 for lesson 4
//Purpose: A program that accepts three integers from the keyboard
// and display the largest and smallest values and display
// the largest and smallest absolute values
//Author: Larsen J Close Most recent changes: 2/12/2016
#include <iostream> // preprocessor directive
#include <iomanip> // needed for most manipulators
#include <cmath> // needed for sqrt()
using namespace std; // using directive
int main ( void )
{
float x;
float y;
float z;
float x1, y1, z1;
float max;
float min;
float absmin;
float absmax;
cout << "Enter three different integers separeted by spaces:";
cin >>x>>y>>z;
cout << " \n\n";
max = x;
min = x;
absmin = x ;
absmax = x ;
if( x >= max) //set for max
max = x;
if ( y >= max)
max = y;
if ( z >= max)
max = z;
if ( x <= min) //set for min
min = x;
if ( y <= min)
min = y;
if ( z <= min)
min = z;
abs(x) = x1;
abs(y) = y1;
abs(z) = z1;
if (x1 <= absmin ) //set for absmin
(absmin = x1);
if (y1 <= absmin )
(absmin = y1);
if (z1) <= absmin )
(absmin = z1) );
if (x1 >= absmax ) //set for absmax
absmax = x1);
if (y1 >= absmax )
absmax = y1;
if (z1 >= absmax )
absmax = z1;
cout << abs (x) << endl;
cout << abs (y) << endl;
cout << abs (z) << endl;
cout << "Smallest value is " << min << endl;
cout << "Largest value is " << max << endl;
cout << "Smallest absolute value is " << absmin << endl;
cout << "Largest absolute value is " << absmax << endl;
system ("pause");
return 0;
} //end main ( )
/* Display for above program
Enter three different integers separeted by spaces:1 2 -3
Smallest value is -3
Largest value is 2
Smallest absolute value is 1
Largest absolute value is 3
Press any key to continue . . .
*/