-
Notifications
You must be signed in to change notification settings - Fork 0
/
t1.c
127 lines (122 loc) · 2.18 KB
/
t1.c
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include<stdio.h>
#include<stdlib.h>
void asc(int a,int b,int c){
if(a < b){
if(b < c){
printf("%d %d %d\n", a, b, c);}
else{
if(a < c){
printf("%d %d %d\n", a, c, b);}
else{
printf("%d %d %d\n", c, a, b);}
}
}
else{
if(b > c){
printf("%d %d %d\n", c, b, a);}
else{
if(a < c){
printf("%d %d %d\n", b, a, c);}
else{
printf("%d %d %d\n", b, c, a);}
}
}
}
void dsc(int a,int b,int c){
if(a < b){
if(b < c){
printf("%d %d %d\n", c, b, a);}
else{
if(a < c){
printf("%d %d %d\n", b, c, a);}
else{
printf("%d %d %d\n", b, a, c);}
}
}
else{
if(b > c){
printf("%d %d %d\n", a, b, c);}
else{
if(a < c){
printf("%d %d %d\n", c, a, b);}
else{
printf("%d %d %d\n", a, c, b);}
}
}
}
void abasc(int a, int b, int c){
a = abs(a);
b = abs(b);
c = abs(c);
if(a < b){
if(b < c){
printf("%d %d %d\n", a, b, c);}
else{
if(a < c){
printf("%d %d %d\n", a, c, b);}
else{
printf("%d %d %d\n", c, a, b);}
}
}
else{
if(b > c){
printf("%d %d %d\n", c, b, a);}
else{
if(a < c){
printf("%d %d %d\n", b, a, c);}
else{
printf("%d %d %d\n", b, c, a);}
}
}
}
void abdsc(int a, int b, int c){
a = abs(a);
b = abs(b);
c = abs(c);
if(a < b){
if(b < c){
printf("%d %d %d\n", c, b, a);}
else{
if(a < c){
printf("%d %d %d\n", b, c, a);}
else{
printf("%d %d %d\n", b, a, c);}
}
}
else{
if(b > c){
printf("%d %d %d\n", a, b, c);}
else{
if(a < c){
printf("%d %d %d\n", c, a, b);}
else{
printf("%d %d %d\n", a, c, b);}
}
}
}
int main(){
int x, y, z, d;
printf("Please input 3 integer numbers:\n");
scanf("%d %d %d", &x, &y, &z);
printf("Please choose the sorting method:\n");
printf("Ascending(input 1), Dscending(input 2)\n");
printf("Absolute Ascending(input 3), Absolute Dscending(input 4)\n");
scanf("%d", &d);
switch(d){
case 1:
asc(x, y, z);
break;
case 2:
dsc(x, y, z);
break;
case 3:
abasc(x, y, z);
break;
case 4:
abdsc(x, y, z);
break;
default:
printf("error\n");
}
return 0;
}